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

댓글 수: 1

Chandra Kurniawan
Chandra Kurniawan 2011년 12월 18일
Vectorization??
Did you mean tracing??
Something such converting raster image to vector??

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2011년 12월 18일

8 개 추천

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

Image Analyst
Image Analyst 2011년 12월 18일
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...
Image Analyst
Image Analyst 2011년 12월 18일
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.
Image Analyst
Image Analyst 2011년 12월 18일
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.
Ashish Bhatt
Ashish Bhatt 2011년 12월 20일
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
Walter Roberson
Walter Roberson 2011년 12월 20일
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Ashish Bhatt
Ashish Bhatt 2011년 12월 20일
Thank you Walter. That helps.
juveria fatima
juveria fatima 2018년 3월 30일
how to get back image from vector

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2011년 12월 18일

댓글:

2018년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by