![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167974/image.jpeg)
How to draw a line across the centre of the barcode?
2 次查看(过去 30 天)
显示 更早的评论
Original Image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146472/image.jpeg)
How to make the image to look like this??
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146473/image.jpeg)
0 个评论
采纳的回答
Chandra Kurniawan
2012-1-10
Hi,
If my understanding of your question is not wrong.
Irgb = imread('rhsr9t.jpg');
Icrop = imcrop(Irgb,[75 25 670 500]);
Igray = rgb2gray(Icrop);
Ibw = im2bw(Igray,graythresh(Igray));
Iarea = bwareaopen(Ibw,300);
Idilate = imdilate(Iarea,strel('line',10,0));
stat = regionprops(Idilate,'Centroid');
linecoor = [0 stat.Centroid(2);
stat.Centroid(1) stat.Centroid(2);
size(Irgb,2) stat.Centroid(2)];
imshow(Icrop); hold on
plot(stat.Centroid(1),stat.Centroid(2),'ro','markersize',10,'linewidth',2);
line(linecoor(:,1),linecoor(:,2),'linewidth',2,'color','g');
And the result :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167974/image.jpeg)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!