Effacer les filtres
Effacer les filtres

The output matrix values are either 0 or 1 but i want it between [0,1]

1 vue (au cours des 30 derniers jours)
image=imread("101_img_.png");
[R,C,~]=size(image);
Red=image(:,:,1);
Green=image(:,:,2);
Blue=image(:,:,3)
red_norm=zeros(size(Red));
red_norm=(Red - min(Red(:)))./(max(Red(:))-min(Red(:)));
green_norm=zeros(size(Green));
green_norm=(Green - min(Green(:)))./(max(Green(:))-min(Green(:)));
red_norm_sum=sum(red_norm(:));
disp(green_norm);

Réponse acceptée

Turlough Hughes
Turlough Hughes le 26 Jan 2020
Modifié(e) : Turlough Hughes le 27 Jan 2020
When you load in the image the data type is uint8 - unsigned 8 bit integers. So you can't get values between 0 and 1 unless you change the data type:
I = imread('101_img_.png');
I = im2double(I);
Your following calculations should go as expected now:
[R,C,~]=size(I);
Red = I(:,:,1);
Green = I(:,:,2);
Blue = I(:,:,3);
red_norm = zeros(size(Red));
red_norm = (Red - min(Red(:)))./(max(Red(:))-min(Red(:)));
green_norm = zeros(size(Green));
green_norm = (Green - min(Green(:)))./(max(Green(:))-min(Green(:)));
red_norm_sum = sum(red_norm(:));
  3 commentaires
Turlough Hughes
Turlough Hughes le 26 Jan 2020
You can just use im2uint8 in a similar fashion, see the following documentation.
Turlough Hughes
Turlough Hughes le 26 Jan 2020
Anything else? If not can you accept the answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by