MATLAB Answers

Error with Imresize as a result of one image file not being in binary

1 view (last 30 days)
Kevin Akash Rajasekaran
Kevin Akash Rajasekaran on 17 May 2021
Answered: DGM on 17 May 2021
Hey all! So I'm calculating a metric (AUC_Borji to be specific) which makes use of a saliency map and a fixation map. According to the original source code, the fixation map is recommended to be in the form of a binary map. When I run the code normally without any of the inputs being in the form of a binary map, I get the following error:
Function IMRESIZE expected input number 2, MAP, to be a valid colormap. Valid
colormaps cannot have values outside the range [0,1].
The error is with respect to this particular line of the code:
if size(saliencyMap, 1)~=size(fixationMap, 1) || size(saliencyMap, 2)~=size(fixationMap, 2)
saliencyMap = imresize(saliencyMap, size(fixationMap))
end
The thing is that when I convert the 'input number 2' i.e fixationMap into a binary map through 'imbinarize', it still gives the above error. What is the problem with the above code plus is there a better way to binarize the image. For reference, the saliency map is 305x539x3 uint8, while the fixation map is 530x673x3 uint8

Answers (1)

DGM
DGM on 17 May 2021
You're using imresize with a completely invalid syntax. Neither of these is an indexed color image or colormap in the sense that imresize() or any IPT tool would expect. A colormap is a simple 2D mx3 matrix.
You're trying to adjust one image to match the geometry of another. If you want image A to inherit the geometry of image B:
s = size(B);
A = imresize(A,s(1:2));
You may want to specify the interpolation method explicitly depending on what you want for your data.

Community Treasure Hunt

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

Start Hunting!