how to combine subimages which is split into window size of 8x8 by using mat2cell into one single image ?
1 view (last 30 days)
Show older comments
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 Comments
Image Analyst
on 6 Mar 2018
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.
Answers (1)
KSSV
on 7 Mar 2018
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)
See Also
Categories
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!