samedi 11 avril 2015

MATLAB: finding values in one array and using those locations to change values in one channel of a separate 3 channel array

So I have a labeled array (array1) with connected regions of interest (background is all zeros, connected regions are all 1's for the first region, all 2's for the second, 3's for the 3rd etc.) I also have a vector (vector1) of the region labels I find important (ex. 1,6,9). I want to find the locations of these values in the labeled array and then change values in one channel of a separate 3 channel array at the same locations (want to color certain parts of an image green based regions of interest found in another image).


I can use the below code to change all channels, but don't know how to specify (img(y,x,1=0), img(y,x,2=0), img(y,x,3=255)).



for i=1:1:length(vector1)
img(array1==vector1(i))=255;
end

Aucun commentaire:

Enregistrer un commentaire