How to transfer this into matlab code

1 visualización (últimos 30 días)
Alaa Ibrahim Eldesoky
Alaa Ibrahim Eldesoky el 6 de Jul. de 2021
Editada: Alaa Ibrahim Eldesoky el 7 de Jul. de 2021
Hello
I need to transfer this code to matlab to use it to get the Normalized red/Grren/Blue index of image
VI=np.zeros((img.shape[0], img.shape[1], 20))
RGB_sum=np.sum(img, axis=2)
R=img[:,:,2]
G=img[:,:,1]
B=img[:,:,0]
rn=R/RGB_sum
gn=G/RGB_sum
bn=B/RGB_sum

Respuesta aceptada

Pamudu Ranasinghe
Pamudu Ranasinghe el 6 de Jul. de 2021
img=imread('img_test.jpg');
RGB_Sum=sum(img,3);
%%%---> Method 1
[R,G,B]=imsplit(img);
%%%Method 2
%R=img(:,:,1);
%G=img(:,:,2);
%B=img(:,:,3);
rn = double(R) ./ RGB_Sum;
gn = double(G) ./ RGB_Sum;
bn = double(B) ./ RGB_Sum;
%If you want to show the Image
imshow(rn,[])
imshow(gn,[])
imshow(bn,[])
  1 comentario
Alaa Ibrahim Eldesoky
Alaa Ibrahim Eldesoky el 7 de Jul. de 2021
Editada: Alaa Ibrahim Eldesoky el 7 de Jul. de 2021
Thanks alot it's work with me
I was transfered the code into this
img=imread('img_test.jpg');
R=img(:,:,1);
G=img(:,:,2);
B=img(:,:,3);
RGB_sum = double(R) + double(G) + double(B);
rn=double(R)./double(RGB_sum) ;
gn=double(G)./double(RGB_sum) ;
bn=double(B)./double(RGB_sum) ;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by