Effacer les filtres
Effacer les filtres

I want to know find height and width of binary image and angle

5 vues (au cours des 30 derniers jours)
Adisorn Phanukthong
Adisorn Phanukthong le 10 Fév 2017
Sample this image output Height 180 Width 145 and find degrees from center of picture 4 angle

Réponses (1)

Guillaume
Guillaume le 10 Fév 2017
Your question is really not clear, at a guess you want the height width and general angle of the white figure in your image. All can be simply obtained with regionprops.
But first of all, JPEG is completely the wrong format for storing binary images:
>>img = imread('bw00018.jpg'); %read image
>>intensities = unique(img(:))' %get list of all intensity values in the image:
intensities =
1×74 uint8 row vector
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
22 23 24 25 26 27 28 29 30 31 34 35 36 37 39 216 217 220 221 222 224 225
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
248 249 250 251 252 253 254 255
Your image is no longer binary due to the way standard jpeg compression works. Use a non-lossy image format such as PNG.
Anyway,
bw = img > 127; %convert to binary image using arbitrary threshold
props = regionprops(bw, 'all');
shapeheight = props.BoundingBox(4)
shapewidth = props.BoundingBox(3)
shapeanglefromhorz = props.Orientation;
Orientation is the angle of the ellipse that best fit your shape.
  5 commentaires
Image Analyst
Image Analyst le 13 Fév 2017
Modifié(e) : Image Analyst le 13 Fév 2017
dx = xRed - xCentroid;
dy = yRed - yCentroid;
angle = atan2d(dy, dx);
Adisorn Phanukthong
Adisorn Phanukthong le 13 Fév 2017
I don't understand please detail more

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by