Matlab reads the image and displays the gray level

The procedure is as follows:

clc, clear, close all;
I = imread('ngc6543a.jpg');
J = rgb2gray(I);
figure, imshow(J);

clc --- Clear command window command

clear --- delete all previously declared and assigned variables, and release system memory

close all --- close all child windows that pop up in matlab

imread(path) --- read the rgb image, and assign the rgb matrix to I, path is the path where the image is located

rgb2gray(I) --- Convert the rgb image I into a grayscale (0 and 1) image, and assign it to the matrix J, I is the rgb image

figure --- Create a window

imshow(J) --- Display the image in the window created by figure, J is the matrix of gray level (0 and 1)

Guess you like

Origin blog.csdn.net/zhunju0089/article/details/80915343