How Can I Remove Small Areas From a Selection/Mask?

Aug 11, 2017

Copy link to clipboard

Copied

I do a lot of product photography. Recently I have to do shots on a coloured background which is replaced in post with a solid colour. Therefore I have to cut all objects from the background.

To get a good initial selection for the cut, I start with a color range selection. Next I add a threshold to this selection to get a sharp edge for the mask. I usually end up with a selection like this:

p1.jpg

Is there a quick way to remove all small "selection isles" and just keep the large continuous areas with the objects?

I tried to use the dusk and scratch filter, but this filter also affects the edges of the products.

Views

665

Likes

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

How Can I Remove Small Areas From a Selection/Mask?

Aug 11, 2017

Copy link to clipboard

Copied

I do a lot of product photography. Recently I have to do shots on a coloured background which is replaced in post with a solid colour. Therefore I have to cut all objects from the background.

To get a good initial selection for the cut, I start with a color range selection. Next I add a threshold to this selection to get a sharp edge for the mask. I usually end up with a selection like this:

p1.jpg

Is there a quick way to remove all small "selection isles" and just keep the large continuous areas with the objects?

I tried to use the dusk and scratch filter, but this filter also affects the edges of the products.

Views

666

Likes

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
Aug 11, 2017 1
Aug 11, 2017

Copy link to clipboard

Copied

Could you rephrase your question? I've read it several times and am having trouble understanding what you are asking.

Likes

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
Reply
Loading...
Aug 11, 2017 0
Aug 11, 2017

Copy link to clipboard

Copied

I would like to get rid of all the small 1x1 - 5x5 pixel blobs in the selection, but keep the large selected object.

Also I would like that this operation does not touch the shape of the selection around the object.

Currently I am using a brush to remove the small spots, but it would be nice if this process could be automated somehow.

Hopefully this clarifies my question.

Likes

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
Reply
Loading...
Aug 11, 2017 0
Aug 11, 2017

Copy link to clipboard

Copied

Hi

The direct answer to your question is that you can click on the mask in the layers panel then paint with white to reveal areas and with black to hide areas.

However - for that sort of product shot, by far the best mask is made with the pen tool.

Set the pen tool to path and draw round it. When done click twice on the mask symbol at the bottom of the layers panel and you will get a vector mask added to your layer. This is very sharp and the path remains adjustable

Draw with Pen tools in Photoshop

Dave

Likes

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
Reply
Loading...
Aug 11, 2017 1
Aug 11, 2017

Copy link to clipboard

Copied

Hi Dave,

Thank you for the answer, this is the method which I currently use. I am wondering if there is some kind of automated way to remove the small spots from the mask, without manually brush them away. I have to do this on 100+ images, and it seems to me this is a task made for computers to do not humans. 🙂

Best,

Likes

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
Reply
Loading...
Aug 11, 2017 0
Aug 11, 2017

Copy link to clipboard

Copied

Hi

Once you have your mask you can make a new selection with the rectangular marquee tool and fill that with black onto  the existing mask. Two rectangles would cover most of your unwanted area in the example above - minimising the brush work.

Dave

Likes

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
Reply
Loading...
Aug 11, 2017 0
Aug 11, 2017

Copy link to clipboard

Copied

If  you are referring to these white specks.

mask.jpg

Option/Click on the mask in the Layers panel (to reveal the mask) and paint the specks in black with a hard edged brush

Likes

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
Reply
Loading...
Aug 11, 2017 0
Aug 12, 2017

Copy link to clipboard

Copied

I recognize that this post has been marked Answered (as well it should be) but since I can’t face up to doing today’s chores, I thought I would hide out here for a while and come up with a solution that does not require pen precision and time or any tedious brush work. You mentioned you were dealing with about 100 images.

1. Open the file and duplicate the layer

2. Draw a rectangular selection around the object in the lower right. Then, inverse the selection.

3. Gaussian Blur the layer to lose the specs. Radius about 8

4. In the History panel click the box next to Gaussian Blur to move the History symbol down to the Gaussian Blur step. Then click on the step before it in the History panel. The white specs will return

5. Edit > Fill with Use: History and Mode: Darker. OK. Done.

6. Deselect the marching ants.

(The reason for Steps 4&5 is that the blue background seems to vary in tone across its surface and that variation should be maintained.)

With 100 images, you may consider an Action some of this work.

Likes

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
Reply
Loading...
Aug 12, 2017 0
Aug 12, 2017

Copy link to clipboard

Copied

Hi Norman,

Thank you very much for this interesting idea! I actually did not mark this question as answered, it seems someone else did. Because actually the answer which is marked as correct answer is not related to my problem.

I do focus stacking in macro photography and have sometimes 500 and more images which I would like to process in a batch and create a mask around the main object in the image. The main object is not always at the same place in the images, but using a simple color range selection I already have a nice base.

I really would like to have some function which just selects continuous areas in the selection/mask which exceed a certain number of pixels. This seems to me an ideal task for a computer algorithm and also something a image processing software should be able to do. Regarding the answers I got it seems Photoshop is not capable of such tasks.

All the best,

Likes

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
Reply
Loading...
Aug 12, 2017 0
Dec 01, 2020

Copy link to clipboard

Copied

How about:

  1. Turn the selection into a layer with only 2 colors (create a new layer and fill the selection with the paint bucket)
  2. Contract the selection by 1 pixel
  3. Expand the selection by 2 pixels
  4. Use the magic wand to remove the extra background from the modified selection

 

2 problems with this method:

  1. It doesn't remove small areas near big areas
  2. You will lose thin protrusions from the big areas

Although you can trade off between these 2 - if you have lots of protrusions but no small areas nearby, you can expand the selection more to include the protrusions.

Likes

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
Reply
Loading...
Dec 01, 2020 0