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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Specifying 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