Matlab 그림 형식 변환 pgm jpg

1050 단어
%        H:\me   \  \     \lfwcrop_grey\lfwcrop_grey\faces\        pgm       jpg    
%        pgm        ,          。
function [  ] = pgm2jpg(  )
 
 %             pgm     
 pgms = dir('H:\me   \  \     \lfwcrop_grey\lfwcrop_grey\faces\*.pgm');
 num_pgms = length( pgms );
 for i = 1 : num_pgms
   pgm_file = fullfile( 'H:\me   \  \     \lfwcrop_grey\lfwcrop_grey\faces\' , pgms(i).name );
   pgm      = imread( pgm_file );
   
%%%     :  pgm_file     jpg     ,   . %%%

%    ,      pgm_file ,  ,pgm_file     +   +  ,  pgm_file = 'H:\me   \  \     \lfwcrop_grey\lfwcrop_grey\faces\test'
% path = 'C:\Users\kitty\test'  name = 'test' ext = '.pgm'
[path,name,ext ] = fileparts( pgm_file ) ;

%    ,       
filename = strcat( name,'.jpg' );

%    ,      
jpg_file = fullfile( 'H:\me   \  \     \lfwcrop_grey\lfwcrop_grey\faces\test' , filename ) ;

%    ,  pgm   jpg_file      ,    jpg   .
 imwrite( pgm , jpg_file , 'jpg' );
 
end
 
end

전환 전
전환 후

좋은 웹페이지 즐겨찾기