Hi,
How Can I convert a JPEG image into a vector?
Thanks, Ashish

1 个评论

Vectorization??
Did you mean tracing??
Something such converting raster image to vector??

请先登录,再进行评论。

 采纳的回答

Jan
Jan 2011-12-18
It depends.
You cannot convert a "JPEG image". JPEG is a file format and files are stored sequentially always. Therefore it is a kind of vector already.
The contents of the JPEG file can be imported as array using imread:
Img = imread(FileName);
For gray-scale images this is a 2D-matrix, for RGB-JPEGs this is a [Width x Height x 3] array. You can convert both to a vector by:
ImgVector = Img(:);
% Or:
ImgVector = rehsape(Img, 1, []);
But I cannot imagine how this could be useful.

9 个评论

Well one use is that you can do this
meanValue = mean(imageArray2D(:));
instead of
meanValue = mean(mean(imageArray));
(similar for min, max, and sum)
but somehow I don't think that's what he meant.
Jan
Jan 2011-12-18
What abount mean2 - a function which I will never use...
Yes, you could use that. I don't think there are corresponding "2" versions of all functions though, just some - for some weird reason.
Jan
Jan 2011-12-18
@Image Analyse: Sigh, sometimes it is tedious, if the OP does not react to comments. I really think we could create much better answers if we know the necessary details. I think, I should do something more efficient.
Sometimes authors come back weeks later to mark their question as solved. Does the system automatically nag authors via email if they haven't marked a question as solved after some time?
By the way I think I've seen lingo like this before where the questioner was wanting a feature vector - a completely different beast. I really wish people would post with a mindset like no one knows what they're talking about and make it so that no one could possibly make bad assumptions. They need to be as explicit as possible. I hate those that can be interpreted 3 different ways. If you get three different answers, each assuming one of the possible assumptions, and only one was right, then they've just wasted two people's time because those people used the assumptions that weren't what the author was intending.
Thanks for the replying guys and sorry for delayed action.
I have further questions. I want to convert a lot of images to vector. For that I need to change 'FileName' every time inside the loop. How to do that? To be explicit:
for i = 1:number of images
Img = imread(FileName); %I want 'FileName' to change everytime loop %executes itself. i.e. for i = 1, Filename = image001; for i = 2, FileName = %image002; and so on.
ImgVector = Img(:); %convert array 'Img' to vector 'ImgVector'
vediomatrix(:,i) = ImgVector; %Store each vector into array 'vediomatrix'
end
Thanks
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Thank you Walter. That helps.
how to get back image from vector

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by