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

조회 수: 7 (최근 30일)
Ryan
Ryan 2014년 7월 15일
답변: Ryan 2014년 7월 15일
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

채택된 답변

Ryan
Ryan 2014년 7월 15일
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

추가 답변 (2개)

Image Analyst
Image Analyst 2014년 7월 15일
Pass Q into improfile() instead of figure(5).

Ryan
Ryan 2014년 7월 15일
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!

Translated by