# Image extraction work

Posted 12 days ago
357 Views
|
6 Replies
|
1 Total Likes
|
 Hello,Hope everyone is doing good and I really need some help with regards to automate the image extraction work.We usually receive team/group images and the majority of the groups are shot on a natural background. We create the path and do the extraction on images.The normal time of doing the extraction is around 30 minutes for 15-18 people, which we want to reduce.Kindly suggest a way to automate or reduce time for such processing.Thank you.
6 Replies
Sort By:
Posted 12 days ago
 Extracting content from images is very dependent on the nature of the image. Can you provide some sample images?
Posted 11 days ago
 Thanks for your reply and usually we receive single person and team images and I have attached one example for both.So team images, I understand time consuming and but atleast if I get 80-90% then rest I will do it manually.Thanks. Attachments:
Posted 11 days ago
 Take a look at this post on MSE. I tried it on your images. I had to make them smaller, otherwise Mathematica requires too much memory. (* Copied from the post *) net = NetModel["Ademxapp Model A1 Trained on ADE20K Data"]; netevaluate[img_, device_: "CPU"] := Block[{resized, encData, dec, mean, var, prob}, resized = ImageResize[img, {504}]; encData = Normal@NetExtract[net, "Input"]; dec = NetExtract[net, "Output"]; {mean, var} = Lookup[encData, {"MeanImage", "VarianceImage"}]; prob = NetReplacePart[ net, {"Input" -> NetEncoder[{"Image", ImageDimensions@resized, "MeanImage" -> mean, "VarianceImage" -> var}], "Output" -> Automatic}][resized, TargetDevice -> device]; prob = ArrayResample[prob, Append[Reverse@ImageDimensions@img, 150]]; dec[prob]] getPeople[i_] := Map[ReplaceAll[{13 -> 1, _ -> 0}], netevaluate[i], {2}] // Image (* Try it on the sample images *) smile = Import["~/Downloads/Smiling Face.jpg"]; smallSmile = ImageResize[smile, 1000]; smileMask = getPeople[smallSmile]; ImageMultiply[smileMask, smallSmile]  (* Same for the other image *) It did not do so well on the second image. One thing you could do is to save the mask. Import the image and mask in Photoshop and manually adjust the mask. That should take less effort compared to starting from scratch.
Posted 10 days ago
 This is an interesting problem. I cannot offer a satisfying solution, but maybe it is helpful though. The striking feature of your sample images is that the focus lies on the foreground, while the background - which is to be removed - is unsharp. This is the basis of my approach. So I first tried something using Fouriertransform, but then I discovered that RidgeFilter is doing the job. (For this demo I am working with downsized images. When working on bigger images, probably some parameters need to be adjusted.) img0 = Import[ "https://community.wolfram.com/c/message_boards/get_message_\ attachment?messageId=1733676&attachment=adult-bangkok-businessmen-\ 1571877.jpg"]; img1c = ImageResize[img0, 1000]; img1g = ColorConvert[img1c, "Grayscale"]; img1gs = Sharpen[img1g]; rfImg = DeleteSmallComponents[Binarize[RidgeFilter[img1gs], .02], 500] From this - using MorphologicalComponents - it easy to create a "background mask": morphComp = MorphologicalComponents[ColorNegate@Dilation[rfImg, 1]]; bgNumber = First[Commonest@Flatten[morphComp]]; bgMask = Erosion[ImageApply[If[# == bgNumber, 0, 1] &, Image[morphComp]], 2] The result is an image with transparent background ... resultImg = RemoveBackground[bgMask img1c] ... so an arbitrary background can be chosen: testImg = ExampleData[{"TestImage", "House2"}]; ImageCompose[ImageResize[testImg, ImageDimensions[resultImg]], resultImg] In case of the first image things do not work that well. But in particular small and critical parts (e.g. the hairs in the wind) can perfectly be separated (using a blue background here as an example): ImageApply[If[# == {0, 0, 0}, {0, 0, 1}, #] &, rfImg img1c] Hope that helps a bit, regards -- Henrik