How to change maximum Index value in MATLAB
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone i hope you are doing well.
I have the following image in which white pixel value exist 35,40,45,55
- I want to find the maximum pixel (index) for example in above 55 is the maximum pixel (index) then add 50 pixel in to to make new maximum value to 105
- Then i want to divided the each pixel value with the maximum value(105). Then map the value to 10000 e.g multiple new pixel value with 10000 so it will map between 1 to 10000
as you can see i have 1's in logical array in position 35,40,45,50,55
I want to shift the values by 50 for examples 33 to 88 and 55 to 105.
Then i will divided the index value by new maximum value which is 105.
for example 35/105=0.333 which then multiple by 10000 which gives the results 3333 Now the 1's start should be in the index 3333
same for remaining value
for example 55 is maximum value then 55/105=0.5238 which is multiple by 10000 which is 5238 is the maximum value where 1's exist.
4 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 14 de Ag. de 2022
Editada: KALYAN ACHARJYA
el 14 de Ag. de 2022
I re-read the question again-
- I want to find the maximum pixel (index) for example in above 55 is the maximum pixel (index) then add 50 pixel in to to make new maximum value to 105
Lets say data is an 2D gray image, int8, having maximum pixel value is 255 (considering pixel range 0-255)
%Lets add 50 on those pixel having more than 55 pixel value
im_data=uint8(data>50)*55;
result_im=data+im_data;
Imp Note: Have you noticed that the maximum number of pixels in a Unit 8 image cannot exceed 255? On the other hand you can do the same approach assuming the pixel values to be a pure matrix and do all the calculations (avoid unit 8 conversion).
Let's say data variable is double data type
%Lets add 50 on those pixel having more that 55
data=double(data);
im_data=double(data>50)*55;
result_im=data+im_data;
Let's say maximum value is 305, code is as follows
>> max(result_im(:))
- Then i want to divided the each pixel value with the maximum value(105). Then map the value to 10000 e.g multiple new pixel value with 10000 so it will map between 1 to 10000
max_val=max(result_im(:));
result_mat=result_im/max_val;
% Map the values in between 1 to 10000
result=interp1([min(result_mat),min(result_mat)],[1,10000],result_mat);
Hope it helps!
Kalyan
Ver también
Categorías
Más información sobre Matrix Indexing 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!