Get pixel identities with different resolutions but same field of view
2 views (last 30 days)
Show older comments
AbioEngineer
on 21 Dec 2020
Answered: Hrishikesh Borate
on 31 Dec 2020
Let's say I took an image of the same thing, but one is 512x512 and one is 256x256 pixels. The second one has 1/4th as many pixels, so any given pixel in that second image corresponds to 4 pixels in the first image. Essentially I want to cluster the 256x256 image into two rough groups, and replace the pixels in image2 that get clustered into group 1 with the corresponding pixels in the 512x512 image1, and the same with the group2 pixels: swap those pixels in image2 with the corresponding pixels in image1.
Is there a quick way to find which pixels of a higher resolution image correspond to a pixel in a lower resolution image? Infographic below
EDIT: The graphic below is just a simplified illustration. If I were to perform kmeans or some other clustering algorithm on the image on the left, and identified pixel #2 to belong to one group, and pixels #1, 3, 4 to belong to another group, I want to return the pixels in the right image that belong to those corresponding groups. i.e. pixel 2 in the first image would correspond to pixels 3,4,7,8 in the right image. I'm not sure how the pixels are numbered in matlab but I'm pretty sure I can just define it myself. So would this just have to be some tedious algebra where I would have to multiply the (potetially self-defined) xy position of the pixel in the left image by 2, or more generally some ratio of image sizes? or is there a better way to map this such that I can just superimpose the xy designations from the left image onto the image on the right, so that all the green squares in the right image (pixels 3,4,7,8) are just assigned a label of "2"?
2 Comments
Image Analyst
on 21 Dec 2020
I'm not sure I follow. In the diagram, which image is the 256x256 and which is the 512x512? And I see 4 quadrants in each, and in the right image, each quadrant has 4 subquadrants. I have no idea what you want to "cluster". What are the two groups? I don't see two of anything. What do you want as an output? An image? A list of (row, column) pixel coordinates? Please explain a lot better.
In the meantime, try dividing or multiplying by 2, or using mod() or rem(). That's all I can think of to suggest until we get a clearer picture of what you want.
Accepted Answer
Hrishikesh Borate
on 31 Dec 2020
Hi,
I understand that given an image in both higher and lower resolution, you want to identify pixel locations of higher resolution image, which correspond to lower resolution image.
Following code is a quick way to do the same.
input = magic(4);
disp(input);
scale = 2;
indices = 1:scale:length(input);
indices = [indices,length(input)+1];
count = 1;
for i=1:length(indices)-1
for j = 1:length(indices)-1
disp(count+":-");
disp(input(indices(i):indices(i+1)-1,indices(j):indices(j+1)-1));
count = count+1;
end
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!