Image processing for pattern restoration
16 ビュー (過去 30 日間)
古いコメントを表示
Hi.
I am working on restoring unclearly printed rectangular patterns using MATLAB. All original patterns are exact rectangular, and I am taking photos for collecting original printed images by a camera. The attached images show the original image used (first), the filled image extracted through the written code (second), and the desired final image (third). My goal is to achieve an image like the third one. The edges do not need to be perfectly rectangular; a rough restoration is sufficient. Any clue would be helpful to me. Thank you.
clc; clear;
imFile="image1.jpg";
Image_Original=imread(imFile);
Image_Gray=rgb2gray(Image_Original);
Image_Inversed = imcomplement(Image_Gray);
Image_BW = imbinarize(Image_Inversed);
Image_BW_filled = imfill(Image_BW,"holes");
edges = edge(Image_BW_filled, 'Canny');
imshow(Image_BW_filled)
0 件のコメント
採用された回答
Matlab Pro
2024 年 5 月 27 日
Hi
Finiding the 4 corners of the rectangle - is very easy (looking for minimum/maximum non zero index on each dimention)
Here is a small example:
W = 20; H = 120;
Image_BW_filled = zeros(W*3,H*1.2);
Image_BW_filled(W*1:W*2-1,20:H+20-1) = rand(W,H)> 0.1;
hFig = figure;
ax = axes('Parent',hFig);
imshow(Image_BW_filled,'Parent',ax)
x1 = find(sum(Image_BW_filled)>0,1, 'first');
x2 = find(sum(Image_BW_filled)>0,1, 'last');
y1 = find(sum(Image_BW_filled,2)>0,1, 'first');
y2 = find(sum(Image_BW_filled,2)>0,1, 'last');
corners = [...
x1,y1; ...
x1,y2; ...
x2,y1; ...
x2,y2];
hold(ax,'on');
hLine = line('XData',corners(:,1),'YData',corners(:,2),'Parent',ax,'Marker','o','MarkerFaceColor','r','LineStyle','none');
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!