Improfile picky about direction line is chosen...

1 次查看(过去 30 天)
Below you'll find the code that's giving me grief. I use improfile to chose a slice of my data initially, and then use the coordinates of that slice to choose other slices to find the intensity along.
Unfortunately, it seems to have a preference for how I choose that initial slice. If I draw my line from the bottom of the image to the top of the image, it works fine (it doesn't care if it's straight or skewed). But if I choose the slice from the top of the image to the bottom of the image, when I reuse the coordinates, the intensity profile always comes out larger than the size of the coordinates.
I'm not sure why improfile should care? This is really baffling. Of course one answer is to always pick from bottom to top, but...there should be a way around this (in fact, I can't think of a logical reason it's even doing this...)
close all clear all
cd('C:\Users\Tiffany\Documents\PhD\PhantomImages\Grid\grid\100A\40V_grid_lowexp') fname = '40V_grid_lowexp.tif'; tot_lin=110;%Choose number of sections of image intensity to compare info = imfinfo(fname);%Reads information about multi-page tif file automatically
%Choose a setup image k=100; %choose an image that should have a plasma discharge image= imread(fname,k,'Info',info);
imshow(image) [cx,cy,c]=improfile; step=5; y=improfile(image,cx,cy);
for i=1:tot_lin line(cx+step*(i-1),cy) eval(['[cx' num2str(i) ']=cx+step*(i-1);']) eval(['[cy' num2str(i) ']=cy;'])
% line(cx,cy+step*(i-1)) % eval(['[cx' num2str(i) ']=cx;']) % eval(['[cy' num2str(i) ']=cy+step*(i-1);']) end
offset=0;%Pick first image to start with num=1;%Pick number of images to sample for i=(offset+1):(offset+num) image = imread(fname, i, 'Info', info);%Imports phantom image as uint8. figure for j=1:tot_lin eval(['y' num2str(j) '=improfile(image,cx' num2str(j) ',cy' num2str(j) ');'])
if j>1
eval(['test_x=horzcat(test_x,cx' num2str(j) ');'])
eval(['test_y=horzcat(test_y,cy' num2str(j) ');'])
eval(['test_z=horzcat(test_z,y' num2str(j) ');'])
else
test_x=cx1;
test_y=cy1;
test_z=y1;
end
end
contourf(test_x,-test_y,test_z)% Minus y because matlab counts pixels from top to bottom
colormap('jet')
colorbar
F(i-offset)=getframe(gcf);%Capture current figure; will be used as movie frame
close all
end
te_st=VideoWriter('contour.avi')
te_st.FrameRate=7;%Set frame rate for move. Number of frames/s
open(te_st)
writeVideo(te_st,F)
close(te_st)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by