• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Remove Small Pixel Areas From Mask?

Explorer ,
Aug 12, 2017 Aug 12, 2017

Copy link to clipboard

Copied

To be honest, I asked the same question before here, but it seems it was completely misunderstood. So I ask it again, more technical in the hope I get some useful answers.

I do macro photography with focus stacking and sometimes after a foto shoot have a huge amount of photos to process (sometimes 150, sometimes 500 and more). All these photos are shoot on a coloured background, but all are slightly different. The photos have something in common: On every photo, the object I would like to select using a mask has the largest continuous area on the image.

Using a color range selection I already have a very good base for the selection. The following image is the mask after a simple color range selection. It is obvious, the main object fills the largest area in this mask.

mask1.png

The mask contains very small specks, from dust and reflections which are not part of the object. See the following image for a close up detail of the same mask from above:

mask-detail.png

My Question is:

Is there an automated way for batch processing, using a filter, plug-in, script etc. to just select the largest area in the mask?

Or is there a way just to remove small specks/areas/blobs in the mask.

Using a brush, or do a manual selection is out of question. It should work fully automatic with no manual input required.

Views

2.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Aug 12, 2017 Aug 12, 2017

Copy link to clipboard

Copied

Is there an automated way for batch processing, using a filter, plug-in, script etc. to just select the largest area in the mask?

If the first image should be clipped and the »frame«-segments were to link up they might turn out to be »bigger« both in height, width and area than the »relevant« part. 

A workaround might be to load the selection, invert, expand by X, contract by (X + Y), invert, intersect with the existing Mask. 

But there may be issues with the »holes« in the main object.

Maybe you should start with showing the actual images instead of just showing the Masks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2017 Aug 12, 2017

Copy link to clipboard

Copied

Considering you're working with a mask, so there's no "automated" way for Photoshop to distinguish which particular white parts you want to keep, I can't think of a fully automatic way to select exactly what you want to keep.

If I wanted to automate this, I'd create an action with a pause for interaction at the selection point. Yes, I'd do a manual selection, but it needn't be crazy (at least as far as what you're showing us). I'd say a quick swipe with the magnetic lasso, or quick select (although I'm not a fan of it's soft edges for this kind of work), then continue with inversing the selection and filling with black would be the quickest and most specific way to get the selection you'd want.

Another method - although, again, not completely automated, might be to loose lasso your main object prior to running Select>Color Range. That way, you're restricting what colors'll be picked up in the first place, limiting a lot of the junk that ends up in your resulting mask.


Adobe Community Expert / Adobe Certified Instructor

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2017 Aug 12, 2017

Copy link to clipboard

Copied

Most of what you can do with an image layer, can also be done to a Layer Mask, albeit only in B&W, so running ​Filter > Noise > Dust & Scratches​ cleans up the mask.  A value of 6 gets you nearly there without doing too much damage, and it also smooths the outline of the object you are masking.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2017 Aug 13, 2017

Copy link to clipboard

Copied

it also smooths the outline of the object you are masking.

That could be addressed by expanding the result and intersecting it with the original.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

I have the same question, and an observation: why is it so difficult to accomplish this? Even measly Corel PhotoPaint has had a "remove holes from mask" option for years! But after extensive googling, I can't find a solution or an action to accomplish this. Heck, if Corel can implement this, it can't be impossible. I'm surprised nobody has figured it out and created an action for it. I might even pay for the action!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 29, 2017 Aug 29, 2017

Copy link to clipboard

Copied

LATEST

If you have a CC subscription After Effects has an effect that can do this perfectly. You could load the images in as an image sequence, process them in AE and then output them again as another image sequence.

The effect I'm talking about is Keylight. It's designed for keying green screen footage but has a lot of matte cleanup tools include. The Despot feature of Kelight is designed specifically for this purpose and would work a treat. It allows you to set a threshold and to despot either white or black "spots". Please ask if you need more help with this.

hope this helps,

Angie Taylor | Creative Cabin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines