How to retrieve specific pixels from an image based on the label

1 次查看(过去 30 天)
Hello everyone,
I am conducting some works on image restoration, particularly on specular reflection removal. I have obtained some results and I would like to evaluate the performance of my method using some quantitative metrics suh PSNR, SSIM, COV, etc. However, I would like to compute these metrics only for the regions that have restored. Please, how can I retrieve only the pixels of the restored regions from the processed images? This is the code I wrote for computing the evaluation metrics for the entire image.
allPSNR = zeros(1, numImages);
allSSIM = zeros(1, numImages);
for k = 1 : numImages
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
baseFileName1 = theFiles1(k).name;
fullFileName1 = fullfile(theFiles1(k).folder, baseFileName1);
lab = imread(fullFileName);
img = imread(fullFileName1);
allPSNR(k) = psnr(img, lab);
allSSIM(k) = ssim(img, lab);
end
meanPSNR = mean(allPSNR);
meanSSIM = mean(allSSIM);
  3 个评论
Patrice Gaofei
Patrice Gaofei 2021-1-1
Thank you for your comments. Yes, I do have the binary image that will help map out the regions. That is what I call label.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2021-1-1
See if it will work for one-dimensional vectors:
allPSNR(k) = psnr(img(binaryImage), lab(binaryImage));
allSSIM(k) = ssim(img(binaryImage), lab(binaryImage));
  6 个评论
Image Analyst
Image Analyst 2021-1-2
Of course pixel values at different locations can be equal. What if you had a completely uniform image where every single pixel in the entire image had the same gray scale value or RGB color? Maybe I'm not understanding what you're trying to say.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by