0
A
回答
0
對於這個問題,我們假設字母在黑色背景(0)上是白色的(1)。 (即,圖像的外側是黑色)
以下MATLAB腳本使用腐蝕,膨脹的組合工作,填充和AND/OR/NOT邏輯運算:
%This script assumes the input image is a binary bitmap image
%Otherwise use:
%BW = logical(BW); after loading grayscale image with BW = imread(filename);
BW = imread('img.bmp'); %read in the image
figure
imshow(BW) %show original image
%for the outside edges
BW2 = imfill(BW, 'holes'); %fill holes in letters
BW3 = imerode(BW2, strel('disk',1));
BW4 = BW2 & (~BW3); %outside boundary of letters (8 connected)
figure
imshow(BW4) %show outside edges
%for the inside edges
BW2 = imerode(BW3, strel('disk',1)); %erode filled letters again
BW3 = ~(BW & BW2); %logical AND operation of original image and doubly eroded filled letter image
BW2 = ~imfill(BW3,1); %fill image with white (1), starting at 1,1 leaves
BW3 = imfill(BW2, 'holes'); %fill inner holes
BW2 = BW3 & (~BW2); %logical operation to isolate inner holes
BW3 = imdilate(BW2,strel('disk',1))-BW2; %boundary of inner edges
BW2 = BW3 | BW4; %logical OR operation to obtain inside and outside edges
figure
imshow(BW2) %final image
相關問題
- 1. 二進制形狀
- 2. Matlab的:獲取二進制圖像輪廓的法線點
- 3. OpenCV:枚舉二進制圖像中的形狀?
- 4. 形狀相似度量二進制圖像
- 5. 使用OpenCV從二進制圖像中分解簡單形狀
- 6. 洪水在二進制圖像中填充形狀
- 7. 繪製圖像的形狀
- 8. 計算二進制圖像上的邊界矩形
- 9. 獲得在ASP.NET MVC上傳文件(影像)的二進制
- 10. matlab:限制對二進制圖像的侵蝕
- 11. 用於以二進制形式獲取輸出的Matlab SVM
- 12. 在Matlab中將二進制圖像轉換爲灰度圖像
- 13. 如何在MATLAB中乘以二進制圖像和RGB圖像?
- 14. Matlab - 如何使用二進制圖像掩蓋三維圖像
- 15. 二進制圖像
- 16. 從二進制圖像獲取灰度圖像的像素值
- 17. Matlab二維圖 - 二進制顯示軸
- 18. (Matlab)在二進制圖像上使用imfilter進行高斯濾波的性能
- 19. 獲得的形狀繪製HTML5的Canvas
- 20. 在matlab中的二進制圖像連接破碎的圓圈?
- 21. 使用MATLAB在圖像上繪製矩形框
- 22. Matlab圖形的Plotedit狀態
- 23. 從二進制圖像中分割圓形圖形
- 24. 如何在不規則形狀的框架中適合圖像
- 25. Java自定義形狀的框架使用圖像
- 26. 將二進制圖像顯示爲視頻的Matlab
- 27. 圓和二進制圖像的交點MATLAB
- 28. 作物基於其二進制圖像 - Matlab的
- 29. 如何用matlab可視化二進制文件像圖像?
- 30. Matplotlib繪製圖形上的形狀
可以使用實驗的[ Canny邊緣檢測器](http://en.wikipedia.org/wiki/Canny_edge_detector)以及非最大抑制。這些[講義幻燈片](http://www.cs.illinois.edu/class/sp12/cs543/lectures/Lecture%2006%20-%20Edge%20Detection%20-%20Vision_Spring2012.pdf「Edge Detection,UIUC CS 543 「)也可能對你有用,從第29頁左右開始。 – cyang 2012-08-03 15:37:01
matlab中的幾個'edge'探測器也是如此。只需查看「邊緣」功能即可。配合「bwmorph」,你應該能夠解決問題。否則,您可能需要創建自己的過濾器,並將「imdilate」和「imerode」與特別設計的結構元素結合使用。 – 2012-08-03 16:28:30
考慮到圖像中的缺陷,我會專注於找出填充字符的可靠方法,然後使用邊緣檢測器或形態學操作來查找邊界。在損壞的圖像上應用邊緣檢測可能會拾取角色內部缺陷的邊緣,這是您不想要的。 – sfstewman 2012-08-03 21:40:36