Re: color threshold



"nirav darji" <nirav_bme@xxxxxxxxxxx> wrote in message <glrv46$cni$1@xxxxxxxxxxxxxxxxxx>...
Hello,

I am Nirav Darji. i am working with image processing.
I have one RGB image.
I am using " colorbar' command to see the shade of colors with values.
Now my question is I want to arrange a threshold which neglect unwanted colors.
I mean i arrange lind of window which take only colors which is inside in this window.
Rest color pixel dont count in my program.
I hope i have explain my question accuratly.
Thank you.

Nirav

The way I have tackled this in the past is to use the concept of colour distance.

1) Define the colour that is in the centre of your acceptable window, say R,G,B
2) Define your colour distance using say Euclidean distance
Dist = sqrt((R-r)^2+(G-g)^2+(B-b)^2)
where r,g,b is the colour of each pixel. You could of course use something like city block distance just as well.
3) What you have, after doing this operation on every pixel in your colour image, is essentially a greyscale image whose intensity is inversly proportional to the closeness to your chosen colour.
4) Convert this Distance image into a binary mask by thresholding at a value which is equal to your acceptable colour window width.
5) Use this binary mask and apply to your original image, you will find that the only pixels left are those which meet your colour range criteria.

Clearly, once you have understood the concept, you can code it up very much more efficiently than the steps I have explained above. i.e. once you have calculated the colour distance of a pixel, you can directly decide whether to keep it or not. But it is worth going the long way round first time for pure education.

Hope that helps

Dave Robinson

.



Relevant Pages

  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... a typo in my example: window width should be 300 and window center 40. ... For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. ... Finally the resultang y,How can i use this y to adjust W/l? ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)
  • Re: capture screen even when workstation is locked
    ... /// Number of adjacent color bits for each pixel. ... PHYSICALWIDTH = 110, ... paper has a physical height value of 6600 device units. ... /// Only the client area of the window is copied. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Double hires mode color artifacts
    ... because areas with the same pattern ... pixel on host pixel boundaries. ... A filter of 4 bit width in hires (which ... to actually employ the wider window, nor do I have a convincing case ...
    (comp.sys.apple2)
  • Re: contour shading
    ... Determine the level at the current pixel, ... Locate two distance measures to the level below, ... to use a 2d pixel traversal algorithm which tested a "ray". ... If the ray hit a pixel with the desired level, ...
    (comp.graphics.algorithms)
  • Re: GetDC() overlapping window problem
    ... However when using GetDC() the window needs to be visible. ... window, or a pixel on the window, is not visisble the value written in the ... currently the forground thread. ...
    (microsoft.public.win32.programmer.gdi)

Loading