How to extract a vector from an image?
古いコメントを表示
Hello,
I have this image

and I want to extract only the velocity vector from the image. Is there a code to do so?
Thank you in advance
2 件のコメント
Walter Roberson
2017 年 2 月 21 日
Do you mean that you want to do optical character recognition to read the '43.6406' ?
Efstathios Kontolatis
2017 年 2 月 21 日
採用された回答
その他の回答 (2 件)
Walter Roberson
2017 年 2 月 21 日
0 投票
The blue vector is the only area in which:
- blue is notably greater than 0;
- and red is low
Red is low in the black sections near the edges, but blue is low for those.
Blue is notably greater than 0 for the grey and white portions, but red is not low for those.
9 件のコメント
Efstathios Kontolatis
2017 年 2 月 21 日
Walter Roberson
2017 年 2 月 21 日
img = imread('1.png');
R = img(:,:,1);
B = img(:,:,3);
r_thresh = 20; %a guess
b_thresh = 50; %a guess
mask = R < r_thresh & B > b_thresh;
mask3 = mask(:,:,[1 1 1]);
masked_image = zeros(size(img), class(img));
masked_image(mask3) = img(mask3);
Efstathios Kontolatis
2017 年 2 月 21 日
Walter Roberson
2017 年 2 月 21 日
Efstathios Kontolatis
2017 年 2 月 21 日
Walter Roberson
2017 年 2 月 22 日
... then you throw away everything that is not a digit or '.' and you convert the string that remains to a double?
Or you could
velocity = sscanf(TheString, 'v=%f')
which would do the conversion for you, assuming it really was able to figure out the literal 'v' and literal '=' and did not add any spacing. It is safer to assume it might have gotten those wrong.
Image Analyst
2017 年 2 月 22 日
Who created that image? Was it your code? Or someone else's? Why not just ask them to output the vector endpoints and number? If you're stuck with the annotated RGB image then you'll need to do as Walter says but only if you have hundreds of images, otherwise you'll spend less time just using ginput(2) to get the endpoints and typing the number you see into inputdlg(), unless you want to write the code just for the fun of it Actually getting the all the points along the blue line is easy with Walter's code - it's the OCR that is the hard part if you don't have the Computer Vision System Toolbox.
Efstathios Kontolatis
2017 年 3 月 10 日
Walter Roberson
2017 年 3 月 10 日
Try thresholding in the bounding box of the text and inverting to turn the text from black to white.
Image Analyst
2017 年 3 月 10 日
You started with just an image, then you found the outline somehow, and used plot(x,y,'g-') to plot the green outline, and you probably used annotation() to draw the blue arrow. Then you used
vText = sprintf('v=%.4fm/s', v);
text(x, y, vText, 'Color', 'k', 'BackgroundColor', 'y');
You had to do that because the text won't just magically appear in the image. So you already know what v is. If you don't, then explain how the yellow text got there.
カテゴリ
ヘルプ センター および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
