I need to layer 2 images so I can select the same region of both images at once

1 visualización (últimos 30 días)
I am comparing optical densities of film. I have one film that was scanned pre-exposure and after exposure (1 film, 2 images).
I need to compare the optical densities of the two different images relative to the same region.
I was curious if it would be possible to layer the two images or create an array that is something like MxNx2 with img1=(M,N,1) and img2=(M,N,2).
When I display the array, I only need to see the exposed film. But when I select a region from the image, I need perform calculations on that region for both layers. So basically I need to select the region and get an array variable for the top layer and a different variable of the same size and location for the bottom layer that isnt being displayed
Questions, comments, suggestions?

Respuestas (2)

Image Analyst
Image Analyst el 19 de Dic. de 2011
You can use roipolyold() or imfreehand() to draw regions on the image. The image could be just one of the images, or it could be where you averaged the images together,
averageImage = (single(image1)+single(image2))/2;
or it could be where you put each image into one color channel:
rgbImage = cat(3, image1, zeros(size(image1)), image2);
Then you can convert the coordinates of the region you drew into a binary image with poly2mask(). Then extract the pixels in the region from each image
image1ROI = image1(binaryImageMask); % A linear 1D vector.
image2ROI = image2(binaryImageMask);
  2 comentarios
Justin
Justin el 30 de Dic. de 2011
img=imread('TestIMG.jpg');
imshow(img1);
roi=imrect
pos=getPosition(roi);
mask=poly2mask(pos(1),pos(2),pos(3),pos(4));
img1ROI=img1(mask);
this returns an empty img1ROI.
Justin
Justin el 30 de Dic. de 2011
Because my images are exactly the same size, it seems I should be able to just use 'pos' to get the pixel values for the location and size of roi for any of my images.

Iniciar sesión para comentar.


Justin
Justin el 30 de Dic. de 2011
Got it I think. Really simple.
In short:
img1=imread('myImage1'); img2=imread('myImage2');
imshow(img2)
roi=imrect
pos=getPosition(roi);
img1ROI=imcrop(img1,[pos]);
img2ROI=imcrop(img2,[pos]);
  1 comentario
Image Analyst
Image Analyst el 30 de Dic. de 2011
How did you "get it"? That doesn't do anything like the "layering" you asked for. No average image, no color image with each gray image as a color channel. Nothing at all like you asked me initially. All you're doing it cropping two images at the same locations. Anyway, you might find rbbox() easier to use than imrect().

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by