how to combine subimages which is split into window size of 8x8 by using mat2cell into one single image ?

1 回表示 (過去 30 日間)
rikki
rikki 2018 年 3 月 6 日
編集済み: rikki 2018 年 3 月 7 日
a=VideoReader('test.mp4 ');
b = read(a,1 );
c=rgb2gray(b );
nframe=a.NumberOfFrames ;
for i=115:116
prev_frame =read(a,i-1 );
e=rgb2gray(prev_frame );
figure
imshow(e );
pause(0.2)
current_frame =read(a,i);
h=rgb2gray(current_frame );
figure
imshow(h);
rows = 8 ;
columns = 8 ;
[H,W,~] = size(c );
szH = [repmat(fix(H/rows),1,rows )];
szW = [repmat(fix(W/columns),1,columns )]; //to split into window size of 8x8 as per my algorithm
C = mat2cell(e, szH, szW )';
D = mat2cell(h, szH, szW )';
figure
for j=1:rows*columns
subplot(rows,columns,j), imshow( C{j } ) //to plot above cells
end
figure
for j=1:rows*columns
subplot(rows,columns,j), imshow( D{j } )
end
for k=1:1*8
o=1:1*8
G=cell2mat(C(k,o)');
figure
imshow(G);at this point i am getting images which i am not able to recombine.kindly suggest something here
end
for k=1:8
o=1:8
H=cell2mat(D(k,o)');
figure
imshow(H);
end
w=std(double(G));
figure
plot(w);
b=std(double(H));
figure
plot(b);
level=graythresh(G);
level=graythresh(H);
if level>level1
T=im2bw(G);
figure
imshow(T);
else
P=im2bw(H);
figure
imshow(P);
end
end
What is mistake in the code? Actually after splitting into window size of 8x8 by using mat2cell() I am not able to reconstruct back into the whole image which is needed as per the algorithm in order to perform other operations. So plz suggest some command or technique.
  2 件のコメント
Image Analyst
Image Analyst 2018 年 3 月 6 日
Tip: in the MATLAB editor, type control-a (to select all), then control-i (to fix indenting), then control-c to copy, then come here and type control-v (to paste). Then highlight the code and click the {}Code icon button above the edit text box.
rikki
rikki 2018 年 3 月 7 日
sir i have done the changes

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2018 年 3 月 7 日
Read about cell2mat.
c = cell(2,2) ;
for i = 1:2
for j = 1:2
c{i,j} = rand(2) ;
end
end
iwant = cell2mat(c)
  1 件のコメント
rikki
rikki 2018 年 3 月 7 日
編集済み: rikki 2018 年 3 月 7 日
is there any other command other than cell2mat to recombine all 8x8 images again into one image which i have got from mat2cell? and please check from there imshow(G); here only i am stuck which is affecting the desired output

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by