Get pixel identities with different resolutions but same field of view

조회 수: 2 (최근 30일)
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
Image Analyst
Image Analyst 2020년 12월 21일
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.
AbioEngineer
AbioEngineer 2020년 12월 21일
Thanks for your comments. I have edited the question. I'm just wondering if it has been done before, and if so whether it's better to do mod(), rem(), or to try and create a map/template that can I can use to look up which pixels in a high resolution image occupy the same area of a pixel in a lower resolution image

댓글을 달려면 로그인하십시오.

채택된 답변

Hrishikesh Borate
Hrishikesh Borate 2020년 12월 31일
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개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by