I am trying to use the reshape function in my code, however, I keep getting a reshape error
RMphantom = imresize(whatisit,[128 128]); % Rescaled
% Set the parameters for the RM phantom.
N = 64; % The image is N-times-N.
theta = 3:3:180; % No. of used angles.
k_art = 20; % No. of iterations.
k_sirt = 20; % No. of iterations.
x = RMphantom;
b = radon(RMphantom,theta)/255;
ntheta = length(theta);
p = length(b)/ntheta;
X = reshape(x,N,N);
Error using reshape
To RESHAPE the number of elements must not change
How would I correct this reshape error? Workspace file is also attached.

 채택된 답변

Steven Lord
Steven Lord 2021년 7월 7일

0 개 추천

Let's look at the relevant bits of your code, shall we?
%{
RMphantom = imresize(whatisit,[128 128]); % Rescaled
% Set the parameters for the RM phantom.
N = 64; % The image is N-times-N.
x = RMphantom;
X = reshape(x,N,N);
%}
For your reshape call to make sense, x must have N*N elements.
64*64
ans = 4096
Does it? That imresize call implies it will have 128*128 elements (or perhaps 128*128*3.)
128*128
ans = 16384
How do you fit 16,384 elements into a 4,096 element grid?

추가 답변 (1개)

Ryan
Ryan 2021년 7월 7일

0 개 추천

Great, thanks for that!

카테고리

도움말 센터File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 7월 7일

답변:

2021년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by