用matlab給映像分塊並儲存子圖

來源:互聯網
上載者:User

文章出處:http://gzc828.blog.163.com/blog/static/10412366420123510634392/

 

本文的源碼地址是:http://download.csdn.net/detail/zhuzhudeailnn/4959234

這是在指導本科生畢業設計的過程中,想到的一個方法,可以為以後遙感映像的處理做鋪墊: 

 

 

 
[FileName,PathName] = uigetfile('*.*','Select the image'); 
Im=imread([PathName FileName]);
imshow(Im)
hold on
L = size(Im);
height=160;
width=160;
max_row = floor(L(1)/height);%實驗圖片為800*1280,則max_row=5,max_col=8
max_col = floor(L(2)/width);
seg = cell(max_row,max_col);
%分塊
for row = 1:max_row     
    for col = 1:max_col       
    seg(row,col)= {Im((row-1)*height+1:row*height,(col-1)*width+1:col*width,:)};  
    end
end
for i=1:max_row*max_col
imwrite(seg{i},strcat('m',int2str(i),'.bmp'));   %把第i幀的圖片寫為'mi.bmp'儲存
end
%畫出分塊的邊界
for row = 1:max_row     
    for col = 1:max_col 
 rectangle('Position',[160*(col-1),160*(row-1),160,160],...
         'LineWidth',2,'LineStyle','-','EdgeColor','r');
        end
end
hold off

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.