问题
I am currently working on code which takes a stack of images and calculates the intensity profiles of these stacks to compare them with another stack of images.
Here's my code:
for i = 1:c_frames
d_Img(:,:) = d_I(i,:,:);
c_Img(:,:) = c_I(i,:,:);
c_d = improfile(d_Img);
c_c = improfile(c_Img);
end
These are the set of errors (all pertaining to one error of course) that I get:
When I whos
d_I and c_I, this is what I get:
So what exactly does the error mean, I tried to look into the documentation, but I wasn't sure as to what the N
meant.
Thank you for your answers and please do not hesitate to ask any questions that will further clarify the question.
回答1:
Granted that this is a cryptic error message, I think the set of inputs you are providing to the improfile
function isn't complete. If you look clearly at https://www.mathworks.com/help/images/ref/improfile.html, you see that the improfile(n)
syntax needs a scalar 'n' (not an image), which is the number of points to include, in the profile.
There is no syntax that allows passing in only an image. You'd have to also include the x and y coordinates of the endpoints of the line segments you want to generate a profile on. For example,
load mri
D = squeeze(D)
dSlice = D(:,:,16);
x = [19 35 65 77];
y = [96 45 27 33];
improfile(dSlice, x, y) % x and y are required inputs.
works. As for the error message, if you're really curious, try
edit improfile
I believe N stands for the number of points you've specified, the way you call it chokes this logic.
来源:https://stackoverflow.com/questions/35123896/not-sure-where-my-code-is-going-wrong-when-using-improfile-in-matlab