フィルターのクリア

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

5 ビュー (過去 30 日間)
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 2 月 10 日
Sample this image output Height 180 Width 145 and find degrees from center of picture 4 angle

回答 (1 件)

Guillaume
Guillaume 2017 年 2 月 10 日
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 件のコメント
Image Analyst
Image Analyst 2017 年 2 月 13 日
編集済み: Image Analyst 2017 年 2 月 13 日
dx = xRed - xCentroid;
dy = yRed - yCentroid;
angle = atan2d(dy, dx);
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 2 月 13 日
I don't understand please detail more

サインインしてコメントする。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by