Im fairly new to MatLab and am taking an elective course which required MatLab while doing my MBA (yes, totally different field). As part of the assignment, we have to use MatLab colormapping to convert the yellow object in the image below into green:
I've used the "imread" function and imported it into Matlab. I also have some experience with colormap with Matlab, but quite basic. In the hints provided, it is said that I should use the IMTOOL function to determine the range of r,g,b values for the yellow pixels and the background pixels. I'm supposed to design a color mapping algorithm that transforms the yellow object to green, but not touch any of the background at all.
In my previous exercise, we converted the 255 values to be just 1s and 0s by dividing by 255. We then created a new colormap and applied it which converted the colors. But I still have no idea how to bring this all together. I've tried some code I found from the Matlab help, but I'm not getting anywhere. My approach has been to import image into Matlab, read image matrix. For all pixels that are close to the pixels of yellow, I replace them with a generic green pixel. Is there a better way to do this? If not, how would I do this with simple MatLab code?
Also, I've checked the code in this function, and I'm 10000000% sure what they are asking me doesn't have to be so complicated: https://www.mathworks.com/matlabcentral/fileexchange/26420-simplecolordetection
As requested, this is the code I have so far. It is a mix of C and MatLab as I understand what needs to be done and I made a quick and dirty C for loop to do it, and now am trying to convert it to MatLab:
for i = 1: image.columnlength
for j = 1: image.rowlenght
rgb = image(i, j);
red = rgb(:,1); %rgb(1,:);
green = rgb(:,2);%rgb(2,:);
blue = rgb(:,3);%rgb(3,:);
if( red > 200 && red < 250 && green > 200 && green < 250 && blue > 200 && blue < 250
//image(i, j ) = green
end
end
end
Thanks, Steve