Effacer les filtres
Effacer les filtres

Boundary Extraction Issue Using Image Restoration Techniques

35 vues (au cours des 30 derniers jours)
Yamina chbak
Yamina chbak le 6 Juil 2024 à 11:54
Modifié(e) : Image Analyst le 14 Juil 2024 à 17:39
Hi, I'm working on extracting boundary points from an image, but the output appears inverted. How can I correctly extract boundary points so the image restoration matches the original orientation? Here's my current MATLAB code:
clear all;
img = imread('parol.png'); % Replace with your image file
grayImg = rgb2gray(img); % Convert to grayscale
bwImg = imbinarize(grayImg); % Convert to binary image
% Invert the binary image if necessary
bwImg = imcomplement(bwImg);
% Fill holes in the binary image
bwImg = imfill(bwImg, 'holes');
% Get boundary points
boundaries = bwboundaries(bwImg);
% Extract the main boundary points
boundaryPoints = boundaries{1};
% Plot the boundary points
figure;
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
plot(boundaryPoints(:,2), boundaryPoints(:,1), 'r', 'LineWidth', 2);
hold off;
daspect([1 1 1]);
Thanks!

Réponse acceptée

Image Analyst
Image Analyst le 6 Juil 2024 à 12:12
After you call plot, do this:
axis('on', 'image');
or you can do
axis ij
  6 commentaires
Yamina chbak
Yamina chbak le 9 Juil 2024 à 19:54
Okay, I understand what you're trying to do, but I still find the image is inverted and clear on the y-axis; the numbers should go from bottom to top. Anyway, I will input an inverted image to make the output appear correct.
Thank you @Image Analyst for your help.
Image Analyst
Image Analyst le 9 Juil 2024 à 20:59
Modifié(e) : Image Analyst le 14 Juil 2024 à 17:39
Not sure what you're saying. Both the images have the same orientation, even though one is an image and one is a plot. Perhaps you're confused about the location of the origin for images and plots.
For images and arrays, the top row is row 0 and that is the origin, and the row numbers on the y axis increase as they go from the top left of the axes to the bottom left of the axes.
For plots, which have (x,y) plot coordinate points, the origin (0,0) point, is at the lower left, and the y axis tick labels on the y axis increase as they go from the bottom left of the axes to the top left of the axes.
That's just the convention everyone uses. MATLAB does give you functions to make it appear differently if you don't like the way the convention appears, and I've showed you some of those.
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by