我就再帮你一次吧,或许害了你
- geshi={'*.dcm','Dicom image (*.dcm)';...
- '*.bmp','Bitmap image (*.bmp)';...
- '*.jpg','JPEG image (*.jpg)';...
- '*.*','All Files (*.*)'};
- [FileName FilePath]=uigetfile(geshi,'导入外部图片','*.dcm','MultiSelect','on');
- if ~isequal([FileName,FilePath],[0,0]);
- FileFullName=strcat(FilePath,FileName);
- if ~ischar(FileFullName)
- FileFullName=FileFullName([2:end 1])';
- end
- else
- return;
- end
- D=[];
- n=length(FileFullName);
- for i=1:n
- I=dicomread(FileFullName{i});
- %I=rgb2gray(I);
- D(:,:,1,i)=I;
- end
- D = squeeze(D);
- Ds = smooth3(D);
- hiso = patch(isosurface(Ds,5),...
- 'FaceColor',[1,.75,.65],...
- 'EdgeColor','none');
- hcap = patch(isocaps(D,5),...
- 'FaceColor','interp',...
- 'EdgeColor','none');
- colormap copper
- view(45,30)
- axis tight
- daspect([1,1,.4])
- lightangle(45,30);
- set(gcf,'Renderer','zbuffer'); lighting phong
- isonormals(Ds,hiso)
- set(hcap,'AmbientStrength',.6)
- set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50)
复制代码
注:我导入一些dicom格式的CT图像,生成了一个立体图。如果你的图片是其它格式,请注意修改下面命令
将 I=dicomread(FileFullName{i}); 改为 I=imread(FileFullName{i});
如果图像是真彩图像,别忘了这条命令
I=rgb2gray(I); |