0

I am trying to prepare semantic segmentation masks out of photoshop images. I'd like to have pixel-perfect solid colour masks (in machine learning segmentation sense) for different parts of the image. Here's the example I'm working on:

enter image description here

I select the area to be labelled and fill it with a solid colour. The problem is on the borders - some of the interior pixels are not solid, as they are on the alpha scale.

enter image description here

I've read that photoshop selection is not binary (degree of belonging as an alpha channel rather than selected/not selected), and there are many weird tricks with anti-aliasing, feathering and thresholding. All of this sounds hacky and does not always work in my case. I'm using Photoshop 2023 on OS X.

  1. What's the correct way to create semantic segmentation masks in photoshop? In particular, is there any way to make selection work in a binary mode (without alpha channels)?

  2. Is there a way to ensure that a set of layers (segmentation masks) are disjoint and covers all areas of the image altogether?

2
  • 1
    Hi. Welcome to GDSE. I have no idea what a "semantic segmentation mask" is. Sorry. Photoshop is a photo editor first and foremost, so making masks that are fully black and white is generally not something that it's set up for. Photo masks made with solid pixels would generally look pretty horrible. These "hacks" you mention are probably the best way to do it. Another possibility might be to manually paint on the mask to darken the pixels using the Burn tool, or use a paint brush set to black/white, in Overlay mode. As for your second question, no such functionality.
    – Billy Kerr
    Nov 11, 2022 at 12:42
  • 1
    You can also paint with un-antialiased pixels in photoshop using the Pencil tool.
    – Billy Kerr
    Nov 11, 2022 at 12:49

1 Answer 1

1

There are many ways to make 1-bit masks in Photoshop. For example:

  • Draw with Pencil Tool.

  • Use Lasso Tool with Anti-alias ticked off.

  • Use Polygonal Lasso Tool with Anti-alias ticked off.

  • Use Magic Wand Tool with Anti-alias ticked off.

  • If you already have a mask with anti-aliasing, use Image > Adjustments > Threshold to make it binary.


You also ask for a way to make sure that "a set of layers (segmentation masks) are disjoint and covers all areas of the image altogether".

This is a bit tricky to explain because I don't really know your workflow.

You could start by making your masks and then afterwards clean up by selecting a mask, inverting the selection and deleting that area from all other masks. Sounds easy enough, but requires some thought.

A simpler way might be to draw your masks on one layer without anti-aliasing, using different colors. The layer's Blend Mode could be set to something like Multiply so you can see the image below. That way you could work without giving it much thought and then when you're finished you could select each area with Magic Wand Tool (with Anti-alias ticked off), create a new layer and fill the selection with black.

This is just a quick outline of an idea. Depending on how you would like to work, you can speed up the process using shortcuts, actions and scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.