matlab練習程式(求灰階映像最大灰階,最小灰階,平均灰階)

來源:互聯網
上載者:User

標籤:

轉自 http://www.cnblogs.com/tiandsp/archive/2012/01/07/2316006.html  感謝Dsp tian

clear
clc;
img = imread(‘124.jpg‘);     % Read image from graphics file
[m n t] = size(img);            % 擷取圖型大小  
max = 0;
min = 256;
avg = 0;
for i =1:1:m
    for j = 1:1:n
        if img(i,j)<min
            min = img(i,j);
        end
        if img(i,j) >max
            max = img(i,j);
        end
      avg = avg +double(img(i, j));
    end
end
avg = uint8(avg/(m*n));
m
n
t
max
min
avg

 

  在Matlab中如何讀出、寫入影像檔以及對映像進行簡單處理

Matlab影像處理工具箱支援四種基本映像類型:索引映像、灰階映像、二進位映像和RGB映像。MATLAB直接公影像檔中讀取的映像為RGB映像,它儲存在三維數組中,這個三維數組有三個面,依次對應紅(Red)、綠(Green)、藍(Blue)三種顏色,而面中的資料則分別是這三種顏色的強度值,面中的元素對應於映像中的像素點。設所得矩陣為A三維矩陣(256,256,3),A(:,:,1)代表紅顏色的2維矩陣,A(:,:,2)代表綠顏色的2維矩陣,A(:,:,3)代表藍顏色的2維矩陣。

imread -映像讀取指令

imshow - 映像顯示指令

rgb2ind  - RGB格式映像變為索引格式

im2bw   -  索引格式變為二值映像格式

ind2gray - 索引格式變為灰階格式

 

matlab練習程式(求灰階映像最大灰階,最小灰階,平均灰階)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.