I need help in image processing of the Doppler image. I made the algorithm to rect the region of interest trace the boundary of the waveform and plot it.
image = imread('M.TIF');
% Convert the image to grayscale
grayImage = rgb2gray(image);
[J, rectout] = imcrop(grayImage);
figure; imagesc(J);
% Apply a threshold to segment the Doppler waveform
threshold = graythresh(J);
binaryImage = imbinarize(J, threshold);
imshow(binaryImage);
[rows, columns] = size(binaryImage);
topRows = nan(1, columns);
bottomRows = nan(1, columns);
for col = 1 : columns
t = find(binaryImage(:, col), 1, 'first');
if ~isempty(t)
topRows(col) = t;
bottomRows(col) = find(binaryImage(:, col), 1, 'last');
end
end
hold on;
x = 1 : columns;
plot(x, topRows, 'r-', 'LineWidth', 2);
plot(x, bottomRows, 'r-', 'LineWidth', 2);
% Calculate the time axis based on the total time duration (4.5 seconds)
total_time = 3.6; % seconds
time_values = linspace(0, total_time, columns);
% Plot the Doppler waveform without upper and lower envelopes
figure;
plot(time_values, topRows, 'b-', 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Velocity');
title('Flow velocity Time graph');
grid on;
The problem is that I want output like this with proper Calibration. covert pixel to time around the horizontal axis. The calibration in my result needs to be corrected.The velocity starts from 0, 10,20,30cms/s however, I keep getting different velocity values.Please help me to fix it

