Error message: Colormaps cannot have values outside range (0,1)
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Adam
el 5 de Jun. de 2019
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.
Respuestas (1)
Walter Roberson
el 5 de Jun. de 2019
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 comentarios
Walter Roberson
el 5 de Jun. de 2019
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));
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
