# find intersection between matrix and draw line on a figure

2 views (last 30 days)
Jakub on 29 Aug 2014
Commented: Jakub on 29 Aug 2014
Dear all,
I have a 360X300 matrix that represent fluorescent intensities along the line. Each cell in a column (1:360), has a certain intensity value that changes in time (rows 1:300). The fluorescent signal is slightly moving through time, so at time 0 is in column e.g., 2, than in time point 2, it is in column 5, etc. I would like to draw the line on top of the figure tracing the position of the signal at each time frame, so get the information about the position of the signal at each time frame, i.e. time1 - position 5 time2 - position 7 time3 - position 9, etc.
The signal is noisy so it has to be done manually, this way, no peak finding or similar. I used imfreehand but is gives me information about XY coordinates and not the exact [row column].
Thanks in advance, jakub
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

Image Analyst on 29 Aug 2014
You forgot to post your image. Assuming you can segment out your cell then you just get (x,y) or (column, row) of the spot you want to track/trace and call
plot(x,y, 'r*-', 'MarkerSize', 5, 'LineWidth', 2);
Adjust options as desired.
By the way, imfreehand does give you the x,y coordinates in terms of column, row that are actual for the original full size image, not the on-screen pixels. See attached demo which has code like this:
% User draws curve on image here.
hFH = imfreehand();
% Get the xy coordinates of where they drew.
xy = hFH.getPosition
% get rid of imfreehand remnant.
delete(hFH);
% Overlay what they drew onto the image.
hold on; % Keep image, and direction of y axis.
xCoordinates = xy(:, 1);
yCoordinates = xy(:, 2);
plot(xCoordinates, yCoordinates, 'ro', 'LineWidth', 2, 'MarkerSize', 10);
##### 1 CommentShow -1 older commentsHide -1 older comments
Jakub on 29 Aug 2014
Thank you, it helped a lot!

Sign in to comment.

### Categories

Find more on Image Arithmetic 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!