Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimize noise in drawings; keep only intended shades
I am trying to draw/paint with only 4 gray shades on top of a black background. I am then exporting the drawing to a file that is read into Python with the PIL library (for image processing) as an image mask. When the file created in GIMP is read into Python, a quick look at the values associated with the palette indicates about 20 values. I'm only expecting five values, the background and four gray values, and not sure why this is happening. I think it possibly has to do with pixels that are not one of the shades I'm trying to stick to in the drawing, what I consider noise. I don't have much graphics background, so I may not have the language I need to describe my problem.

My workflow is:
1. Add a new layer over a camera image I'm working with. The new layer has a black background, the HTML notation is 000000. Call it "next".
2. I select the next layer, turn off its visibility to see the camera image with AOIs (Area Of Interest).
3. I use the paths tool to trace the outline of an AOI on next layer. I modify the paths to fit the AOI best I can.
4. I stroke the path to finish that AOI. I use a white color to stroke the paths.
5. I repeat 3 and 4. I have 4 AOIs in each camera image I'm working with.
6. I pick one of HTML notation colors 030303, 070707, 0b0b0b, or 0e0e0e as bucket fill for inside of each AOI.
7. I change the zoom to 200 or 400% to get a good look at the white outline of each AOI. I pick the respective gray per AOI and color over the white outline to make the whole AOI just one shade and get rid of white.
8. I change the mode of the layer to Grayscale in the Image menu.
9. In Layer>Transparency> Remove Alpha Channel
10. I export to PNG and save as 8bpc Gray with no background color.

I import the PNG to Python and then find that there are 16-20 values in the image.

I've attached an example of one of the next images. It's hard to see one of the AOIs because the 030303 is hard to tell from 000000, but you can see that AOIs get darker from one end to the other.

Is there a way to make sure that I'm just getting the background and the four AOI shades in the PNG?

Attached Files Thumbnail(s)
What color was your background initially? I can barely see the four AOI's.
Must be as you said a lot of extra 'greys' as it is a RGB picture now. If you wanted it to be a greyscale you need to go to Image > mode > greyscale.
Maybe someone else can tell you how you 'picked' up noise (Noticable if you desaturate - color to gray)

Hi, sallyanne. The color of the background is 000000 (HTML notation) or 000 (RGB notation). I do try to make it greyscale with step 8. And then I export as a "8bpc Gray".

Then when I import to Python with
from PIL import Image
mask ="next.png")

The mask.mode command tells me that the mode is "L", which is supposed to be some form of grayscale. Thus it seems to be exporting as a grayscale image, I think. I will look into the color>desaturate that you mentioned. Thanks, sallyanne.
There is certainly a specking of odd pixels in the posted image. Why ? I do not know from your procedure. 

Using paths, no need for stroking and bucket fill. Edit -> Fill Path and untick the anti-aliasing option.

You should possibly keep each AOI on its own layer, until your final export.

This looking at your posted png image, a bit of analysis, a bit of a fix.  About 5 minutes:

Wow, rich2005!! That was so helpful! Thank you kindly for the step by step explanation! The video was above and beyond!
Best regards.

Forum Jump: