improfile(), How can I use a .fig format with improfile?

5 views (last 30 days)
Hello all,
I have a .fig file that I want to make multiple profiles for, but improfile doesn't like when I try to pass it as an input.
[x,y,I] = improfile; works when I have a figure already open, but I want to take the initial x that I draw and make additional profiles the next pixel over. So my code looks like this:
figure(5)
imagesc(X,Y,Q,[0 1])
colormap(TSPcolormap);
colorbar;
[Px,Py,I] = improfile; % draw initial profile
for k=1:5
[Qprof(:,k)] = improfile(figure(5), Px+k ,Py);
end
The .fig file is a matrix 600x800 and has a color map so if I try to save it as anything else it loses the scaling and shows up as intensity or RGB instead. So is there a way to tell improfile to read in the current figure?
Also I have tried replacing figure(5) with gcf, gca, etc. To use improfile with initial x and y would have to pass an image through and cannot leave it blank.
Thanks

Accepted Answer

Ryan
Ryan on 15 Jul 2014
Ok figured it out! I needed to add the x and y axes. I also added getimage. Not sure if that was needed, but it ended up working.
figure(5)
imagesc(X,Y,Q,[0 1])
colormap(TSPcolormap);
colorbar;
h = getimage;
[Px,Py,I] = improfile; % draw initial profile
for k=1:5
[Qprof(:,k)] = improfile(X, Y, h, Px+k ,Py);
end

More Answers (2)

Image Analyst
Image Analyst on 15 Jul 2014
Pass Q into improfile() instead of figure(5).

Ryan
Ryan on 15 Jul 2014
Thanks for the fast response! I passed Q through the function, but I returns a matrix of NaN. Any other thoughts?

Community Treasure Hunt

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

Start Hunting!