Skip to content

Commit

Permalink
update Feng
Browse files Browse the repository at this point in the history
  • Loading branch information
bw4sz committed Feb 12, 2025
1 parent 7df197b commit 2dcfc12
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 43 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ We are in the process of release public data, these are datasets that have previ

# Dataloaders

There are 3 datasets for the MillionTrees benchmark:

* TreeBoxes: A dataset of 282,288 tree crowns from 9 sources.

* TreePolygons: A dataset of 362,751 tree crowns from 8 sources.

* TreePoints: A dataset of 191,614 tree stems from 2 sources.
TreeBoxes: 4411 images, 2 splits, 197343 rows
TreePolygons: 18437 images, 2 splits, 760347 rows
TreePoints: 3929 images, 2 splits, 256184 rows

## Why MillionTrees?

Expand Down
46 changes: 12 additions & 34 deletions data_prep/SPREAD.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,44 +366,22 @@ def collect_spread_annotations():
else:
print("No annotations found to combine")

def reverse_rgb_images():
def remove_alpha_channel():
base_dir = "/orange/ewhite/DeepForest/SPREAD"
rgb_folders = glob.glob(f"{base_dir}/*/rgb")

for rgb_folder in rgb_folders:
rgb_images = sorted([f for f in os.listdir(rgb_folder) if f.endswith(".png")])

for rgb_image_file in rgb_images:
full_path = os.path.join(rgb_folder, rgb_image_file)
bgr_image = cv2.imread(full_path)
if bgr_image is None:
print(f"Cannot read image: {full_path}")
continue

rgb_image = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB)
reversed_image = rgb_image[:, :, ::-1] # Reverse the channel order

output_path = os.path.join(rgb_folder, f"reversed_{rgb_image_file}")
cv2.imwrite(output_path, reversed_image)
print(f"Saved reversed image to {output_path}")

# Plot each step using matplotlib
fig, ax = plt.subplots(1, 3, figsize=(15, 5))
ax[0].imshow(cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB))
ax[0].set_title("Original BGR Image")
ax[0].axis("off")

ax[1].imshow(rgb_image)
ax[1].set_title("Converted RGB Image")
ax[1].axis("off")

ax[2].imshow(reversed_image)
ax[2].set_title("Reversed RGB Image")
ax[2].axis("off")

plt.show()
plt.savefig("/home/b.weinstein/MillionTrees/current.png")
for img_file in rgb_images:
img_path = os.path.join(rgb_folder, img_file)
img = cv2.imread(img_path, cv2.IMREAD_UNCHANGED)
if img is not None and img.shape[2] == 4: # Check if image has 4 channels
img = img[:, :, :-1] # Remove the last channel
cv2.imwrite(img_path, img)
print(f"Processed {img_path}")
else:
print(f"Skipped {img_path} (not a 4-channel image)")

if __name__ == "__main__":
#collect_spread_annotations()
reverse_rgb_images()
remove_alpha_channel()
3 changes: 1 addition & 2 deletions data_prep/package_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from deepforest.utilities import read_file
import cv2

version = "v0.1.2"
version = "v0.1.3"
base_dir = "/orange/ewhite/web/public/"

TreeBoxes = [
Expand Down Expand Up @@ -303,7 +303,6 @@
group.root_dir = f"{base_dir}MiniTreePolygons_{version}/images/"
height, width, channels = cv2.imread(f"{base_dir}MiniTreePolygons_{version}/images/" + group.image_path.iloc[0]).shape
source = source.replace(" ", "_")
# Flip BGR and RGB order
plot_results(group, savedir="/home/b.weinstein/MillionTrees/docs/public/", basename=source, height=height, width=width)

# Zip the files
Expand Down
Binary file modified docs/public/Feng_et_al._2025.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2dcfc12

Please sign in to comment.