Error message: Colormaps cannot have values outside range (0,1)
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to analyze the intensity of some images (RGB values) but when I run the code I get this error message:
Error using rgb2hsv>parseInputs (line 101)
Valid colormaps cannot have values outside the range [0,1].
Error in rgb2hsv (line 36)
[r, g, b, isColorMap, isEmptyInput, isThreeChannel] = parseInputs(varargin{:});
Error in AnalyzeIntensity071108 (line 64)
HSV(:,:,image_num)=rgb2hsv(RGB(:,:,image_num));
Has someone had a similar problem? If so, how did you fix it?
Thanks!
댓글 수: 2
Adam
2019년 6월 5일
Make sure your data doesn't have values outside that range. Without seeing any of your code or the image in question it's hard to say anything more. The error message is very clear as to what is wrong. As to why, we need more information to know. Maybe you are trying to pass an Unsigned8 image, although I imagine the error message would be different in that case, maybe you cast it to double without rescaling, maybe any one of a number of things.
답변 (1개)
Walter Roberson
2019년 6월 5일
Your image number is a scalar so RGB(:, :, image_num) is 2d not an rgb image. When you pass 2d to rgb2hsv then you need to pass a colormap of Nx3 values in the range 0 to 1
댓글 수: 2
Walter Roberson
2019년 6월 5일
RGB(:,:,image_num)=[Res1_r;Res1_g;Res1_b]';
does not create an RGB image. The right hand side is a 2D array that starts out putting color panes as additional rows, and then switches over to columns.
RGB(:,:,:,image_num) = cat(3, Res1_r, Res1_g, Res1_b);
HSV(:,:,:,image_num) = rgb2hsv(RGB(:,:,:,image_num));
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
