How do I find the function corresponding to a graph image?
101 views (last 30 days)
Show older comments
Dear MATLAB community,
I am trying to find the mathematical function corresponding to the following green curve (although I would be most thankful for suggestions for the blue one also). Unfortunately, I don't have the underlying data with which it was created. Can anyone help?
Thanks a lot in advance!
Accepted Answer
Mehmed Saad
on 7 Apr 2020
Extract Data
After that you can find mathematical function
4 Comments
Mehmed Saad
on 8 Apr 2020
Edited: Mehmed Saad
on 8 Apr 2020
This is the code, but you have to convert the picture to this format i.e. remove the other parts ( i used microsoft word for that xD)
this is a long method, i copied this code i don't remeber from where
fullFileName ='C:\Users\PROJECT PC\Pictures\data1.png';
rgbImage = imread(fullFileName);
rgbImage = imresize(rgbImage,10);
[rows, columns, numberOfColorBands] = size(rgbImage);
fontSize = 36
subplot(2, 2, 1);
imshow(rgbImage);
axis on;
title('Original Color Image', 'FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
greenChannel = rgbImage(:, :, 2);
binaryImage = greenChannel < 200;
%
subplot(2, 2, 2);
imshow(binaryImage);
axis on;
title('Binary Image', 'FontSize', fontSize);
verticalProfile = sum(binaryImage, 2);
lastLine = find(verticalProfile, 1, 'last')
for col = 1 : columns
yy = lastLine - find(binaryImage(:, col), 1, 'first');
if isempty(yy)
y(col) = 0;
else
y(col) = yy;
end
end
subplot(2, 2, 3);
plot(1 : columns, y, 'b-', 'LineWidth', 3);
grid on;
title('Y vs. X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
%%
y2 = y(174:5213);
t = 0:1/length(y2):1-1/length(y2);
y_norm = y2/max(y2);
figure,plot(t(1:100:end),y_norm(1:100:end))
More Answers (0)
See Also
Categories
Find more on Colormaps 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!