Plotting a linescan thru a centroid and outputting the data
2 views (last 30 days)
Show older comments
Hello. I am struggling for the last day with what should be really simple. I have an image of a spot (called ROI) and I obtain the coordinates of its centroid using a moment of light. After plotting this spot on the original image (to ensure its correct), I want to plot a linescan thru this location so I can see the profile in both horizontal and vertical scans. I limit the size of the linescans to +- a user defined variable (SL). This bit isn't looking right and I can't see why.
axes(handles.axes6);
grid on;
plot(ROI(cenY-SL:cenY+SL,cenX),'r-', 'MarkerSize', 4); %column plot
hold on
plot(ROI(cenY,cenX-SL:cenX+SL),'g-', 'MarkerSize', 4); %row plot
legend on;
legend('column','row');
axes(handles.axes2);
hold on
plot(cenX,cenY,'g.', 'MarkerSize', 6, 'Marker','.');
hold off
I then want to output the data from the linescans into a file, again I have tried the follwoing but its not working. Ideally I would like 4 columns, the first 2 being centroid X data and the last 2 being the centroid y data.
%Output data to file:
xout= cenY-SL:1:cenY+SL %(start:step:finish)
yout= ROI(xout,cenX)
Dataout = [xout; yout];
fileID = fopen('Centroid.txt','w');
fprintf(fileID,'%6s %12s\n','cenx','ceny)');
fprintf(fileID,'%6.2f %12.8f\n',Dataout);
fclose(fileID);
any help would be very much appreciated.
Jason
0 Comments
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!