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

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

回答(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

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by