How to subtract one color from an image?
Show older comments
If I have two images, both having red and black colors with RGB values [1 0 0] and [0 0 0]. The areas covered by red and black colors in both images are different. I just want to show that the two images are similar as they are having the same RGB values. I hope this can be done if somehow I am able to subtract the black color from the images and show that both the leftover color's rgb value is same.(i.e. red, [1 0 0])
7 Comments
Guillaume
on 26 Jan 2017
I don't understand your question.
Black is the absence of colour. It's nothingness. You can't subtract nothing from an image, it does not make sense. As you've noted black in RGB is [0 0 0], subtract 0 from anything and you still have the anything.
Your statement that the two images are similar as they have the same RGB values is bizarre as well. In the previous sentence, you said one has red (RGB [1 0 0]) the other is black (RGB [0 0 0]) with presumably some colour (white?) somewhere else. RGB [1 0 0] is not the same at all as RGB [0 0 0].
Can you clarify what it is you want, preferably with some example images.
Ankurdeep Kaur
on 26 Jan 2017
Adam
on 26 Jan 2017
You should probably edit your original question to make more sense. The images you posted have numerous colours, none of which are black.
Ankurdeep Kaur
on 26 Jan 2017
Adam
on 26 Jan 2017
Well, you can just subtract one from another if your images are red and black only, but it isn't going to give you a very good or useful measure of how similar they are. For a start you will get a mix or positive and negative numbers and it will be very sensitive to any pixel differences.
Ankurdeep Kaur
on 27 Jan 2017
Ankurdeep Kaur
on 27 Jan 2017
Accepted Answer
More Answers (1)
Image Analyst
on 28 Jan 2017
0 votes
This question is very deceptive and confusing. You don't even have these images originally. What you have, and showed in your other post, is a continuous RGB image of a leaf. Then, somehow, in a way you have not shared with us, you classified regions in the leaf and assigned these different class colors. Presumably the different images came from different leaves. It makes little sense to subtract the pseudocolored images. I mean what if one leaf was shifted slightly in the field of view? The whole subtraction would be drastically different! Don't do that. You are on a wild goose chase, going in the wrong direction. Don't waste your time.
What you need to do to compare the images is measure a bunch of things, like area, color, texture, feret diameters, etc. that describe the leaves. Then compare the feature vectors.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!