Image processing for pattern restoration
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daeyeon Koh
el 27 de Mayo de 2024
Respondida: Matlab Pro
el 27 de Mayo de 2024
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 comentarios
Respuesta aceptada
Matlab Pro
el 27 de Mayo de 2024
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!