Ask Your Question
0

how to measure the size of object?

asked 2018-11-28 23:36:04 -0500

processed image after color thresholding

After tweaking the HSV values i'm able to achieve this result, now moving ahead i tried the canny edge detection but it doesn't produce any satisfactory result, My goal is to measure the size of plant. Any idea how do move ahead from this?

edit retag flag offensive close merge delete

Comments

you have a mask now, do findContours, than get the biggest one by minAreaRect or contourArea.

blues gravatar imageblues ( 2018-11-29 04:35:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-01 09:58:23 -0500

supra56 gravatar image

updated 2018-12-01 10:27:47 -0500

!/usr/bin/env python3

#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify area. Then press space-bar to see second window. leaf2

edit flag offensive delete link more

Comments

thanks for the response @supra56, I think measuring the size of plant in pixels would be good idea. like counting the number of pixels Black & blue would give a clear indication of size of plant.

anuragchaudhary004 gravatar imageanuragchaudhary004 ( 2018-12-04 03:49:20 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-28 23:36:04 -0500

Seen: 52 times

Last updated: Dec 01