Get pixel identities with different resolutions but same field of view
4 views (last 30 days)
Show older comments
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"?
Hrishikesh Borate on 31 Dec 2020
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);
scale = 2;
indices = 1:scale:length(input);
indices = [indices,length(input)+1];
count = 1;
for j = 1:length(indices)-1
count = count+1;
More Answers (0)
Find more on Color Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!