-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calculate green view index for each image and attach score as attribute to point #8
Comments
Was able to use Claude Sonnet Vision API to provide a score, here is an example output { |
If we have some images with "known" GVI would like to baseline it against the vision API |
Hey @banjtheman, thanks for exploring options! I should add some notes to the readme - we want to prioritize things that are transparent, efficient, open, low or no cost, and can be run locally if possible.
For the MVP, I would like to match what the Treepedia project did. There are plans to add other analysis options into the tool chain. If you think the Clause Sonnet Vision API offers unique advantages, please post your thoughts onto #10. |
Thanks for the added context!!!! Will add the Claude stuff to #10 Hmm, I couldn't access the paper, do you have a copy somewhere would want to see if we can codify |
Was able to convert the old GreenView_calcuate.py to use some modern frameworks, that all run locally Green view score: import cv2
import numpy as np
from skimage.filters import threshold_otsu
def get_gvi_score(image_path):
"""
Calculate the Green View Index (GVI) for a given image file.
Args:
image_path (str): Path to the image file.
Returns:
float: The Green View Index (GVI) score for the given image.
"""
# Load the image
original_image = cv2.imread(image_path)
# Convert to RGB color space
rgb_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2RGB)
# Calculate ExG (Excess Green)
r, g, b = cv2.split(rgb_image.astype(np.float32) / 255)
exg = 2 * g - r - b
# Apply Otsu's thresholding on ExG
threshold = threshold_otsu(exg)
green_pixels = (exg > threshold).sum()
total_pixels = original_image.shape[0] * original_image.shape[1]
# Calculate the Green View Index (GVI)
gvi_score = (green_pixels / total_pixels) * 100
return gvi_score
print("Green view score:")
print(get_gvi_score("example_greenview_image.jpg")) |
Using the above sample I fleshed this out - had to do it on a sample of 10 points as I don't have enough space to download all the mapillary images for the dataset. Is this in the right area of what you're after?
|
from the Treepedia project, the green view index is calculated in GreenView_Calculate.py
see also this paper: li2015.pdf
please see the previous steps as described in the README and follow those conventions for reading data in and out. we want the process to be geo-file agnostic to the extent possible. and modular so that in the future we can add or modify steps, etc.
the geofile use in the readme example can be downloaded here: https://drive.google.com/file/d/1fpI4I5KP2WyVD5PeytW_hoXZswOt0dwA/view?usp=sharing
we want to read in the main output file (if following the example in the readme, it will be a geopackage), which will have a collection of points and associated metadata.
we want to use the
image_path
to read in the image associated with each point. if available - note that some points will have a "None" value forimage_path
and "NULL" forimage_id
(however, please have a more robust check than watching for a string value of "None" as I think the indicator of no match change in the future). calculate the GVI and then store the value back into the dataset in a new column.not needed if you're using the readme data but some examples of images we want to use include this
and this
and this
The text was updated successfully, but these errors were encountered: