- crop the region?
- correct for perspective/barrel distortion?
- back-calculate the actual signal vectors?
How can I crop rectangles from an image?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ismael Raqi Picardo
am 17 Jan. 2023
Kommentiert: Ismael Raqi Picardo
am 19 Jan. 2023
Hello, I am trying, given an image that contains a grid, to detect it in some way to later be able to crop it and keep it, in my case it is an electrocardiogram, I attach image.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1267320/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1267320/image.jpeg)
I tried apply regionprops, hough, etc.
Thanks in advance!
1 Kommentar
DGM
am 18 Jan. 2023
What are the actual goals?
Do you just need to process this one image, or do you need a method to automatically process any image printed in the same manner?
What all do you actually need to do with the image?
Akzeptierte Antwort
DGM
am 18 Jan. 2023
If I were to answer the question as asked:
inpict = imread('image.jpeg');
% get mask selecting red lines
yccpict = rgb2ycbcr(inpict);
limits = [50 200; 0 255; 135 153];
limits = permute(limits,[2 3 1]);
mask = all(yccpict >= limits(1,:,:) & yccpict <= limits(2,:,:),3);
% get rid of stray blobs
mask = bwareafilt(mask,1);
% get blob location, crop image
S = regionprops(mask,'boundingbox');
outpict = imcrop(inpict,S.BoundingBox);
imshow(outpict)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1267370/image.jpeg)
5 Kommentare
Image Analyst
am 18 Jan. 2023
I can think of lots of ways to approach this but none of them are going to be quick and easy. Nothing in a page full of code. For starters assume that the paper is on a consistent background. Then try to identify the background characteristics (color and texture) and segment that out. Then take the inside (the chart) and find the corners and warp it. Some attached demos and web sites might help.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!