簡體   English   中英

如何在Matlab中從矩陣的單元格數組創建單個圖像?

[英]How to create single image from cell array of matrices in Matlab?

我需要將灰度圖像分成相等的部分,因此我使用了mat2cell函數。 然后,我不得不分別均衡每個部分,為此,我使用了histeq函數。 為此,我重用了相同的單元格數組變量。 這是代碼:

height=round(size(img,1)/number_of_divisions);
length=round(size(img,2)/number_of_divisions);
M=zeros(number_of_divisions,1);
N=zeros(1,number_of_divisions);
M(1:number_of_divisions)=height;
N(1:number_of_divisions)=length;
aux=mat2cell(img,M,N);

for i=1:size(aux,1)
    for j=1:size(aux,2)
        aux{i,j}=histeq(aux{i,j},256);
    end
end

那么現在如何將每個單元合並為一個圖像?

使用cell2mat

img2=cell2mat(aux);

為了獲得更好的性能,請將代碼替換為blockproc

blocksize=ceil(size(img)./number_of_divisions);
img2=blockproc(img,blocksize,@(block_struct)histeq(block_struct.data));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM