Is this possible to convert a thick line or curve into its thinner version

10 次查看(过去 30 天)
Is this possible to convert a thick line or curve into its thinner version in an image using Matlab / Octave? Please view the image. Right side curves (alphabets) are thicker and need to be converted into the left ones. i.e., a single line version is needed.
thanks

采纳的回答

Ahmet Cecen
Ahmet Cecen 2014-11-18
Take an image with the best exposure possible, having high contrast between the paper white and font black. Use a simple tresholding method like Otsu's and get a BW binary image. Use:
a) erosion (imerode) with a disk structural element (strel)
or
b) use bwulterode
or
c) you can also use bwmorph with 'skel' option.
I am sure there are other ways to do it too. Just a couple simple ones that might help start.
  3 个评论
Ahmet Cecen
Ahmet Cecen 2014-11-20
What's happening there is you are eroding on the white instead of black. You need to invert the image using:
BW=1-BW;
so that the pixels where the letters are have 1's on them (which means your image should have white letters and black background). Now try them again. I think Image Analyst is right the first 2 options would only work in very specific conditions, but give them a try anyways its good learning experience.

请先登录,再进行评论。

更多回答(2 个)

Image Analyst
Image Analyst 2014-11-18
You can skeletonize it after thresholding.
binaryImage = grayImage < 128; % or whatever.
skeletonImage = bwmorph(binaryImage, 'skel', inf);
You cannot use imerode() because it will break apart your object into multiple objects. You cannot use bwulterode because it will shrink the blob down to a single point.
  2 个评论
Image Analyst
Image Analyst 2014-11-20
编辑:Image Analyst 2014-11-20
It did not work because you did not do what I recommended . Look at the line where I thresholded. It will take everything that is darker than 128 and turn it white. Why did you not do that? You should notice that I even specifically said NOT to use bwulterode() or imerode(). All I can figure is that this reply was really meant for Ahmet, not for me. I know you accepted his answer already, but if you need any more help, feel free to ask.

请先登录,再进行评论。


baby
baby 2014-11-24
Thanks for your reply. This is first time I asked a question on Matlab forum. I tried techniques from both replies and I wanted to accept answers from both. I prepared reply for both. Regarding accepting answers, I did it for the top one first, then the system did not allow me to do this for the next. Please do not take it personal.
The original one is already threshold. This is strictly black and white image. I am sending coding for this all
% code
a1 = imread('Bee.png'); a2 = rgb2gray(a1); a = thresh_my(a2); % high contrast image; my own created function imshow(a), [max(max(a)) min(min(a))]
b1 = bwmorph(a2,'skel'); %% not working b2 = bwulterode(a2,'quasi-euclidean'); %% not working
se = strel('disk',11); b3 = imerode(a2,se);% eroded a
b4 = bwmorph(a2,'skel',inf);
figure, subplot(321),imshow(a); title('original') subplot(322), imshow(b1) , title('bwmorph with skel') subplot(323), imshow(b2) , title('bwulterode') subplot(324), imshow(b3) , title('imerode with strel: disk 11') subplot(325), imshow(b4) , title('bwmorph with skel: inf')
%% code ends
  1 个评论
Image Analyst
Image Analyst 2014-11-24
Again, this is not my code. You took the skeleton of a2, which is not the binary image. The binary image is the badly-named "a". So you're still not doing what I suggested - perhaps the poor variable names confused you, that's why I recommend using descriptive variable names like grayImage, binaryImage, skeletonImage, etc. Please attach your original B image that you used so I can try it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by