Making an image based off RGB values of other image?

1 visualización (últimos 30 días)
Inderdeep Grewal
Inderdeep Grewal el 27 de Ag. de 2018
Respondida: Naman Chaturvedi el 30 de Ag. de 2018
How would I go about the process of marking an image with a marker based on the RGB values of another image?
Img4.fig shows the file I want to mark up based on the other 4xx, 4xy, and 4yy strain plots. I would like to run an "if" statement using the RGB values located in the same position as the Img4 plot (middle of white area) in the 4xx, 4xy, and 4yy plots. The If statement would compare the RGB values as follows: If sqrt(4xx^2 + 4yy^2) > sqrt(2*4xy^2), use a blue marker else use a red marker. This will help identify areas of shear and tensile cracks.

Respuestas (1)

Naman Chaturvedi
Naman Chaturvedi el 30 de Ag. de 2018
I hope your intention is to compare the images in the middle region where they are varying. I performed the logic operation and marked the image 'img2' accordingly. I hope I understood the problem correctly.
i4xx=imread('4xx.jpg');
i4xy=imread('4xy.jpg');
i4yy=imread('4yy.jpg');
[x y ~]=size(i4xx);
img2=zeros(size(i4xx));
for i=1:x
for j=1:y
if (sqrt(double(i4xx(i,j,:)).^2 + double(i4yy(i,j,:)).^2) > sqrt(2*double(i4xy(i,j,:)).^2))
img2(i,j,:)=[0 0 1];
elseif (all(i4xx(i,j,:)==i4xy(i,j,:)) && all(i4xy(i,j,:)==i4yy(i,j,:)) && all(i4xx(i,j,:)==i4yy(i,j,:)))
img2(i,j,:)=[0 0 0];
else
img2(i,j,:)=[1 0 0];
end
end
end
Hope this helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by