- as integer values stored in an integer data type such as uint8 data or uint32. The associated brightness is TheData/intmax(class(TheData)) such as 123/255 for the stored value 123. In this kind of grayscale image, the integer value 0 is valid and needs to be taken into account
- as floating point values in the range 0 to 1 stored in a floating point array. The associated The associated brightness is the portion given by the floating point value. In this kind of grayscale image, non-integer values of all kinds are valid and need to be taken into account
- as integer values stored in integer data types such as uint8 data, together with a table of floating point brightness values that are in the range 0 to 1. The integer value is used to index into the brightness table, so there is not necessarily any connection between the integer value itself and the brightness that will result. In this kind of grayscale image, the integer value 0 is valid and is the index of the first entry into the table
- as floating point integral values stored in a floating point arra. The integer value is used to index into the brightness table, so there is not necessarily any connection between the integer value itself and the brightness that will result. In this kind of grayscale image, the integer value 0 is likely going to be silently treated as if it was 1 but there "should not" be any such values.
Why am I getting an error 'Subscript indices must either be real positive integers or logicals.'
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Why am I getting this error?
for k = 1 : numel(grayImage)
inputIndex = thisPhase(k);
grayImage(k) = uint8(map1(inputIndex));
end
0 comentarios
Respuestas (2)
Walter Roberson
el 23 de Mzo. de 2016
What do not know what thisPhase is, and we do not know what map1 . But if thisPhase() can contain non-integer values then you would get that error.
In particular grayscale images can be implemented four different ways in MATLAB:
So if the datatype is one of the integer data types, the integer 0 is fully expected, either as representing full black, or as representing the first entry in the lookup table. If the datatype is floating point, then values in the range 0 to 1 might be expected, or integers starting from 1 might be expected, depending what the data is being used for. You might notice that only in one of these four possibilities is it safe to assume that you will not have any values that are 0.
7 comentarios
Walter Roberson
el 3 de Abr. de 2016
What is min(thisPhase(:)) ? What is max(thisPhase(:)) ? What is size(map1) ?
Image Analyst
el 3 de Abr. de 2016
Try this:
% Create look up table
lut = map1(thisPhase);
% Apply look up table
grayImage = intlut(grayImage, lut);
That's all. Nothing else. No for loop or anything. Essentially you're using thisPhase to decide how to order map1. Then map1 is being used as a look up table to map grayImage gray levels to new gray levels.
4 comentarios
Walter Roberson
el 4 de Abr. de 2016
If you use intlut then you should not also do the code at "set custom graymap".
At the beginning of your code you have
map1 = colormap(jet(pCap)); map1(1,:) = [1 1 1];
That defines map1 to be a colormap with pCap entries, but we do not know what the value of pCap is. Unless pCap is at least as great as max(NEW_Stance(:))+1 then you will run into problems with creating the map.
Ver también
Categorías
Más información sobre Custom Geometry and PCB Fabrication 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!