How to crop an image around certain xy coordinates?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Isaiah Stefan Engle
am 27 Feb. 2017
Kommentiert: Image Analyst
am 27 Feb. 2017
This may be a simple question but I am extremely new to Matlab and coding in general. I have the coordinates of a circle's center by using the imfindcircles function. I want to be able to find the total pixel value of a 25x25 pixel box around the given coordinates. I'm not really sure how this can be done at all. Is there a way to plot such a box around a given xy coordinates? Thank you in advance!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Feb. 2017
Given x and y as integers, then
cropped = YourArray(y - 12 : y + 12, x - 12 : x + 12, :);
Assuming that the x and y are not within 12 of the edge of the image.
After that it depends what you mean by "total pixel value". You might mean
sum(cropped(:))
or you might mean
nnz(cropped)
1 Kommentar
Image Analyst
am 27 Feb. 2017
Or maybe use mean2() on the cropped image.
meanInBox = mean2(cropped)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!