Error using imshow function

4 views (last 30 days)
Shane
Shane on 2 Feb 2015
Commented: David Young on 2 Feb 2015
the error I get is
Error using imageDisplayValidateParams Expected input number 2, [LOW HIGH], to be non-NaN.
Error in checkDisplayRange (line 10) validateattributes(display_range, {'numeric'},...
Error in imageDisplayValidateParams (line 53) common_args.DisplayRange = checkDisplayRange(common_args.DisplayRange,mfilename);
Error in imageDisplayParseInputs (line 78) common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 219) [common_args,specific_args] = ...
Error in aceDet (line 14) figure; imshow(SWIR_ACEimgNorm,[])
Error in mat2op (line 150) [VIS_ACEimgNorm,VIS_ACEresults,VIS_ACEimg,SWIR_ACEresults,SWIR_ACEimg, SWIR_ACEimgNorm] = aceDet(VIS_M, VIStarget,SWIR_M, SWIRtarget,m,n);
The code is
function [VIS_ACEimgNorm,VIS_ACEresults,VIS_ACEimg,SWIR_ACEresults,SWIR_ACEimg, SWIR_ACEimgNorm] = aceDet(VIS_M, VIStarget,SWIR_M, SWIRtarget,m,n)
% Apply ACE
VIS_ACEresults = hyperAce(VIS_M, VIStarget);
VIS_ACEimg = hyperConvert3d(VIS_ACEresults, m, n, 1);
VIS_ACEimgNorm = hyperNormalize(VIS_ACEimg);
SWIR_ACEresults = hyperAce(SWIR_M, SWIRtarget);
SWIR_ACEimg = hyperConvert3d(SWIR_ACEresults, m, n, 1);
SWIR_ACEimgNorm = hyperNormalize(SWIR_ACEimg);
figure; imshow(VIS_ACEimgNorm,[])
title('VIS ACE');
figure; imshow(SWIR_ACEimgNorm,[])
title('SWIR ACE');
The VIS_ACEimgNorm will show but the SWIR_ACEimgNorm come up with the error. The variables for VIS_M, VIStarget,SWIR_M, SWIRtarget,m,n are:
  • VIS_M 117x10000 double
  • VIStarget 117x1 double
  • SWIR_M 237x10000 double
  • SWIRtarget 237x10000 double
  • m 100
  • n 100
Please let me know is you need more information and thank you for any help.
  1 Comment
Shane
Shane on 2 Feb 2015
I think I found it in the hyperAce function the values for SWIR_M and SWIRtarget are pulled in but then become NaN in the SWIR_ACEresults which will be a 1x10000 double the code is:
function [results] = hyperAce(M, S)
[p, N] = size(M);
% Remove mean from data
u = mean(M.').';
M = M - repmat(u, 1, N);
S = S - repmat(u, 1, size(S,2));
R_hat = hyperCov(M);
G = inv(R_hat);
results = zeros(1, N);
% From Broadwater's paper
%tmp = G*S*inv(S.'*G*S)*S.'*G;
tmp = (S.'*G*S);
for k=1:N
x = M(:,k);
% From Broadwater's paper
%results(k) = (x.'*tmp*x) / (x.'*G*x);
results(k) = (S.'*G*x)^2 / (tmp*(x.'*G*x));
end

Sign in to comment.

Accepted Answer

David Young
David Young on 2 Feb 2015
Edited: David Young on 2 Feb 2015
Almost certainly, every element of SWIR_ACEimgNorm is NaN (Not a Number). It's not possible to say how this has come about, but you can start debugging, first by putting this line in the code before the call to imshow, to check my hypothesis:
disp(all(isnan(SWIR_ACEimgNorm(:))))
If that prints 1, then you could start working backwards through the code to see at what point NaNs start to appear in the arrays. Or, you could start by checking the arguments to the function and then working forwards. In either case, you can do this either in the debugger or by inserting additional statements into the code, whichever you are more comfortable with.
  2 Comments
Shane
Shane on 2 Feb 2015
After using
disp(all(isnan(SWIR_ACEimgNorm(:))))
I traced it to where I read in the spectral signature and a misplaced number. When I read in the first half (i.e. VNIR) and assigned it to a variable
pixVnir(:,i)=pix(1:118);
the signature and all data were fine; however when I originaly read the SWIR in i put
pixswir(:,i)=pix2(357:end);
which only read the last column instead of the whole wavelength. This compounded problem giving the SWIR region a flat or inf number which in the end returned a NaN. So I made the correction such that
pixswir(:,i)=pix2(119:end);
Thank you all for your Replies
David Young
David Young on 2 Feb 2015
Glad you got it fixed quickly!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!