I have done segmentation of tumor kind for the slice of the MR images . I want to calculate the area of the segmented region in Python. Can anyone help me in this regard?
CodePudding user response:
I think you can just count the number n of white pixels in your segmented image and multiply it by the area of a single pixel in your image A. n*A is the area you are looking for. Of course, A should be converted to the unit of measurement that you prefer.
CodePudding user response:
Opencv has a function to calculate area of a contour.
contour = numpy.array([[[0,0]], [[10,0]], [[10,10]], [[5,4]]])
area = cv2.contourArea(contour)
To find area you should convert desired area to 1 anf other area to zero. Then find all contour(or contours ) in your image. Finally calculate tumor area.