Graph in tiff format : how to interchange X and Y axis ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a graph in PNG format. I don't have the basic data to generate another graph. I want to inter-change the X and Y axis ? How can I extract the data from image?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/717714/image.png)
0 commentaires
Réponses (1)
Wan Ji
le 21 Août 2021
I usually use GetData software. while with matlab, I wrote code for this problem below
% Extract data from image
clc;clear
figName = input('Insert the name of you picture(jpg or png)\n','s');
myFig = imread(figName);
figure(11)
imshow(myFig);
xmin = input('min of x:');
xmax = input('max of x:');
ymin = input('min of y:');
ymax = input('max of y:');
nCurve = input('input number of curves: n\n');
title('click left_up corner and right c_down orner in the axis:')
[xcor, ycor] = ginput(2);
Curve = struct([]);
for i = 1:1:nCurve
title(['Please click the points of ',num2str(i),'th curve(end with enter)'])
[Curve(i).x , Curve(i).y]= ginput(100);
Curve(i).x = xmin+(Curve(i).x - xcor(1))./(xcor(2)-xcor(1))*(xmax-xmin);
Curve(i).y = ymin+(Curve(i).y - ycor(2))./(ycor(1)-ycor(2))*(ymax-ymin);
end
figure(12)
Leg = cell(nCurve,1);
color = 'rgbkcmrgbkcmrgbkcm';
marker = '^osd><hvposd><hvposd><hvp';
for i = 1:1:nCurve
plot(Curve(i).x,Curve(i).y, [color(i),'-',marker(i)],...
'markerfacecolor',color(i),'markersize',5)
hold on
Leg{i,1} = ['Line ',num2str(i)];
end
axis([xmin xmax ymin ymax])
legend(Leg);
xlabel('X')
ylabel('Y')
set(gca,'fontsize',15)
save(['Curve',figName,'.mat'],'Curve')
0 commentaires
Voir également
Catégories
En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!