Re: color threshold
- From: "Dave Robinson" <dave.robinson@xxxxxxxxxxxxx>
- Date: Thu, 29 Jan 2009 11:21:01 +0000 (UTC)
"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
.
- References:
- color threshold
- From: nirav darji
- color threshold
- Prev by Date: "Index exceeds matrix dimensions" with own objects and their methods
- Next by Date: Re: Creating variable file names using mkdir
- Previous by thread: color threshold
- Next by thread: count Bytes in a row
- Index(es):
Relevant Pages
|
Loading