Мы поможем в написании ваших работ!



ЗНАЕТЕ ЛИ ВЫ?

imwrite(blue_img, 'Blue4_BerkeleyTower.png', 'png');



subplot(131);

imagesc(img(:,:,1));

title('Red');

subplot(132);

imagesc(img(:,:,2));

title('Green');

subplot(133);

imagesc(img(:,:,3));

title('Blue');


We we issue a command colormap gray, the picture turns into a grayscale:

>> colormap gray


Want to play more? Then, let's make a new image that has more blue by quadrupling the component. The standard image format is uint8 (8-bit integer), which may not like arithmetic operation and could give us errors if we try mathematical operations. So, we may want to do image processing by casting our image matrix to double format before we do our math. Then we cast back to uint8 format at the end, before displaying the image.

subplot(211);

imshow(img);

title('Normal RGB');

subplot(212);

blue_img = double(img);

blue_img(:,:,3) = 4*blue_img(:,:,3);

blue_img = uint8(blue_img);

imshow(blue_img);

title('RG 4*B');

Конец формы

 

imwrite()

To save your new blue image, use the imwrite() command:

imwrite(blue_img, 'Blue4_BerkeleyTower.png', 'png');

rgb2gray()

img = imread('ImageProcessing_1/BerkeleyTower.png');

gray = rgb2gray(img);

imshow(gray);

 

>> size(gray)

ans =

499 748

Now, we have only one value for each pixel not 3 values. In other words, the rgb2gray()converted RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.

imhist()

Display a histogram of image data. imhist(img,n) displays a histogram with n bins for the intensity image above a grayscale colorbar of length n. If we omit the argument, imhist() uses a default value of n = 256 if I is a grayscale image, or n = 2 if I is a binary image.



Поделиться:


Последнее изменение этой страницы: 2024-06-17; просмотров: 20; Нарушение авторского права страницы; Мы поможем в написании вашей работы!

infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 18.227.72.15 (0.009 с.)