试验一 matlab读取图像
clear all, close all; path=\'C:\Users\Administrator\Desktop\\';
file_jpg=strcat(path,\'t1.jpg\');
%读取jpg图像
I1=imread(file_jpg); imshow(I1);
%读取dicom医学图像 file_dicom=strcat(path,\'ct1.dcm\'); I2=dicomread(file_dicom); figure;imagesc(I2); colormap(\'gray\'); dicominfo(file_dicom);
%将I1以0.1(或0.3)的压缩比储存 imwrite(I1,strcat(path,\'t2.jpg\'),\'Quality\',10)); imwrite(I1,strcat(path,\'t3.jpg\'),\'Quality\',30)); %绘制I1 R G B 三个通道的直方图 figure(\'color\',\'white\'); imagesc(I1(: ,: ,1); colormap([(0, 1/255, 1)\',zeros(256,1),zeros(256,1)]); axis=off; figure(\'color\',\'white\'); imagesc(I1(: ,: ,2); colormap([zeros(256,1),(0, 1/255, 1)\',zeros(256,1)]); axis=off; figure(\'color\',\'white\'); imagesc(I1(: ,: ,3); colormap([zeros(256,1),zeros(256,1),(0, 1/255, 1)\']); axis=off;
%绘制不同通道的直方图 figure(\'color\',\'white\'); for i=1:3 subplot(:,:,i);imhis(I1(:,:,i)); title(strcat(\'r g b channel\',num2str(i)); end
%把图像I1转换为HSV图像,分别显示H S V三个通道对应的图像
I1_hsv=rgb2hsv(I1); colormap(\'hsv\'); cmap=colormap; cmap=resize(cmap, [256,3],\'bicubic\'); cmap(1,:)=[1.0,1.0,1.0] figure(\'color\',\'white\'); imagesc(I1_hsv(: ,: ,1); colormap(cmap); axis off; axis equal; axis tight; figure(\'color\',\'white\'); imagesc(I1_hsv(: ,: ,2); colormap(\'gray\'); axis off; axis equal; axis tight; figure(\'color\',\'white\'); imagesc(I1_hsv(: ,: ,3); colormap(\'gray\'); axis off; axis equal; axis tight;
请发表评论