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

1 comentario

Chandra Kurniawan
Chandra Kurniawan el 18 de Dic. de 2011
Vectorization??
Did you mean tracing??
Something such converting raster image to vector??

Iniciar sesión para comentar.

 Respuesta aceptada

Jan
Jan el 18 de Dic. de 2011

8 votos

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 comentarios

Image Analyst
Image Analyst el 18 de Dic. de 2011
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 el 18 de Dic. de 2011
What abount mean2 - a function which I will never use...
Image Analyst
Image Analyst el 18 de Dic. de 2011
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 el 18 de Dic. de 2011
@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 el 18 de Dic. de 2011
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 el 20 de Dic. de 2011
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 el 20 de Dic. de 2011
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Ashish Bhatt
Ashish Bhatt el 20 de Dic. de 2011
Thank you Walter. That helps.
juveria fatima
juveria fatima el 30 de Mzo. de 2018
how to get back image from vector

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Dic. de 2011

Comentada:

el 30 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by