Update Image RGB value for many pixels with logical index
Show older comments
Hello all, I'm doing my first steps with MatLab, and faced a problem for several hours now that I'm unable to solve.
If have converted an RGB image to a double matrix, which works. Now I want to modify all pixels of the RGB matrix that have a value >=0.7 in the green channel. I determine the indexes of those pixels using a logical Matrix:
logical_mark_green = my_image_double(:,:,2) >= 0.7; %store logical Matrix containing a '1' at all indexes where value of index 2 (=green) >= 0.7
Afterwards, and that's where I am stuck, I want to overwrite the determined pixels to the colour black:
my_image_double(logical_mark_green, :) = 0; %overwrite image on indexes stored in logical Matrix with 3D-Array representing black colour
But I only get a corrupted image with a small black line. Can anybody help me out? I appreciate any help. And kindly provide beginner-friendly answers :)
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!