[ad_1]
リンゴ、トマト、レモン、オレンジ、グァバ、グーズベリーのバイナリ イメージの体積、面積、周長、長軸、短軸、離心率を計算する必要があります。 これまでのところ、体積と面積の両方で同じ値が得られると計算されましたが、体積を計算する方法は?
私が試したこと:
import cv2 import pandas as pd from skimage import measure # List of binary images image_list = ["/content/drive/MyDrive/Apple Sample 1/15 1.jpg", "/content/drive/MyDrive/Apple Sample 1/15 2.jpg", "/content/drive/MyDrive/Apple Sample 1/16 1.jpg"] # Empty list to store extracted features feature_list = [] # Iterate through the list of images for image_name in image_list: # Read in binary image of apple binary_image = cv2.imread(image_name,0) # Find contours in the binary image contours, _ = cv2.findContours(binary_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Extract the first contour cnt = contours[0] # Calculate the perimeter of the contour perimeter = cv2.arcLength(cnt, True) # Extract region properties of apple regions = measure.regionprops(binary_image) # Extract features of interest for region in regions: volume = region.area area = region.area eccentricity = region.eccentricity major_axis = region.major_axis_length minor_axis = region.minor_axis_length # Create a dictionary with extracted features feature_dict = {"Volume":volume, "Area": area, "Perimeter": perimeter, "Eccentricity": eccentricity, "Major axis": major_axis, "Minor axis": minor_axis} # Append the features of each image to the feature_list feature_list.append(feature_dict) # Convert the list of dictionaries to a dataframe df = pd.DataFrame(feature_list) # Print the dataframe print(df)
解決策 1
見る ソリッド ジオメトリ[^] ソリッド シェイプに適用するさまざまな式について説明します。
[ad_2]
コメント