Image to Vector
显示 更早的评论
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
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
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
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!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
