Subscripted assignment dimension mismatch need help

hello every one, Why do I get the following error message
Subscripted assignment dimension mismatch.
Subscripted assignment dimension mismatch.
Error in r (line 27)
X(i)=x(:,:,k)
ytis is my code
C=imread('D29.gif');
x1=imresize(C,0.4);
x2=im2double(x1);
[m,n,k]=size(x1) % and m=n with 1 channel k=1
ImageSize=m*n;
BlockD=32;
BlockSize=BlockD*BlockD;
NoOfBlock=ImageSize/BlockSize;
SubB=zeros(BlockD,BlockD,NoOfBlock); %arrays of blocks.
% X=zeros(BlockD,BlockD,NoOfBlock);
% important to convert uint8 to double when dialing with image.
% thats what ru asking for.
k=1;
for i=1:BlockD:m
for j=1:BlockD:n
x(:,:,k)=x2(i:i+BlockD-1,j:j+BlockD-1);
k=k+1;
end
end
for k=1:64
for i=1:64
X(i)=x(:,:,k)
i=i+1
end
end

Answers (1)

C=imread('D29.gif');
x1=imresize(C,0.4);
x2=im2double(x1);
[m,n,k]=size(x1) % and m=n with 1 channel k=1
ImageSize=m*n;
BlockD=32;
BlockSize=BlockD*BlockD;
NoOfBlock=ImageSize/BlockSize;
SubB=zeros(BlockD,BlockD,NoOfBlock); %arrays of blocks.
% X=zeros(BlockD,BlockD,NoOfBlock);
% important to convert uint8 to double when dialing with image.
% thats what ru asking for.
k=1;
for i=1:BlockD:m
for j=1:BlockD:n
x(:,:,k)=x2(i:i+BlockD-1,j:j+BlockD-1);
k=k+1;
end
end
X = cell(64,64) ;
for k=1:64
for i=1:64
X{i,j}=x(:,:,k) ;
end
end
YOu need to rethink on your code.

This question is closed.

Asked:

on 2 Apr 2019

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!