I am using this code to convert .jpg file to maltab .fig but in matlab lab file there is no figure represented and if I want to convert more than one .jpg files to fig how can I. I am attaching two files
Show older comments
img = imread('~~.jpg');
imshow(img);
savefig('~~~.fig');
5 Comments
I'm not really sure what your question is. This works fine:
img = imread('circle_shear_rate.jpg');
imshow(img);
savefig('shear.fig')
Muhammad Khan
on 29 May 2018
Paolo
on 29 May 2018
How are you opening the image? Try the following:
openfig('shear.fig','visible')
Muhammad Khan
on 29 May 2018
Walter Roberson
on 30 May 2018
Duplicated by later https://www.mathworks.com/matlabcentral/answers/403123-i-have-matlab-figures-in-jpg-file-how-can-i-export-data-points-of-the-graph-in-excel which also has answers.
Answers (2)
KSSV
on 29 May 2018
images = dir('*.jpg') ;
N = length(images) ;
% loop for each image
for i = 1:N
I = imread(images(i).name) ;
[filepath,name,ext] = fileparts(images(i).name) ;
imshow(I) ;
savefig([name,'.fig']);
end
6 Comments
KSSV
on 30 May 2018
Muhammad Khan commented: I need to convert .jpg to .fig file in matlab and then extract data from that file to excel. How can I do that above codes does not work.
KSSV
on 30 May 2018
When you read the image using imread, already you have data in hand...why/what you want to plot and then extract?
Muhammad Khan
on 30 May 2018
KSSV
on 30 May 2018
I = imread(images(i).name) ;
The above code, gives you matrix I, which is a 3D matrix if the image is RGB.
Walter Roberson
on 30 May 2018
You need to digitize the image like I mentioned. There are a number of File Exchange contributions for this purpose.
Muhammad Khan
on 30 May 2018
Walter Roberson
on 30 May 2018
0 votes
Look in the File Exchange and search for tag:digitize as I have marked a number of routines designed to extract plot information from images.
It would be much easier to extract the data before you wrote them as .jpg files.
Categories
Find more on Convert Image Type 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!