Fahimeh Orvati Nia
commited on
Commit
·
151802d
1
Parent(s):
970a1c0
make texture bettter
Browse files
sorghum_pipeline/data/preprocessor.py
CHANGED
|
@@ -23,10 +23,10 @@ class ImagePreprocessor:
|
|
| 23 |
|
| 24 |
def process_raw_image(self, pil_img: Image.Image) -> Tuple[np.ndarray, Dict[str, np.ndarray]]:
|
| 25 |
"""Split the 4-band RAW into tiles and build composite + spectral stack."""
|
| 26 |
-
#
|
| 27 |
w, h = pil_img.size
|
| 28 |
-
if w >
|
| 29 |
-
scale =
|
| 30 |
pil_img = pil_img.resize((int(w * scale), int(h * scale)), Image.BILINEAR)
|
| 31 |
|
| 32 |
d = pil_img.size[0] // 2
|
|
|
|
| 23 |
|
| 24 |
def process_raw_image(self, pil_img: Image.Image) -> Tuple[np.ndarray, Dict[str, np.ndarray]]:
|
| 25 |
"""Split the 4-band RAW into tiles and build composite + spectral stack."""
|
| 26 |
+
# Keep high resolution for better texture quality (1536x1536 max)
|
| 27 |
w, h = pil_img.size
|
| 28 |
+
if w > 1536 or h > 1536:
|
| 29 |
+
scale = 1536 / max(w, h)
|
| 30 |
pil_img = pil_img.resize((int(w * scale), int(h * scale)), Image.BILINEAR)
|
| 31 |
|
| 32 |
d = pil_img.size[0] // 2
|
sorghum_pipeline/pipeline.py
CHANGED
|
@@ -268,16 +268,16 @@ class SorghumPipeline:
|
|
| 268 |
pdata['texture_features'] = {}
|
| 269 |
spectral = pdata.get('spectral_stack', {})
|
| 270 |
|
| 271 |
-
# Compute texture on green band with
|
| 272 |
if 'green' in spectral:
|
| 273 |
green_band = np.asarray(spectral['green'], dtype=np.float64)
|
| 274 |
if green_band.ndim == 3 and green_band.shape[-1] == 1:
|
| 275 |
green_band = green_band[..., 0]
|
| 276 |
|
| 277 |
-
# Downsample to
|
| 278 |
h, w = green_band.shape[:2]
|
| 279 |
-
if h >
|
| 280 |
-
scale =
|
| 281 |
green_band = cv2.resize(green_band, None, fx=scale, fy=scale, interpolation=cv2.INTER_LINEAR)
|
| 282 |
if mask is not None:
|
| 283 |
mask_resized = cv2.resize(mask, (green_band.shape[1], green_band.shape[0]), interpolation=cv2.INTER_NEAREST)
|
|
|
|
| 268 |
pdata['texture_features'] = {}
|
| 269 |
spectral = pdata.get('spectral_stack', {})
|
| 270 |
|
| 271 |
+
# Compute texture on green band with high quality (512x512)
|
| 272 |
if 'green' in spectral:
|
| 273 |
green_band = np.asarray(spectral['green'], dtype=np.float64)
|
| 274 |
if green_band.ndim == 3 and green_band.shape[-1] == 1:
|
| 275 |
green_band = green_band[..., 0]
|
| 276 |
|
| 277 |
+
# Downsample to 512x512 for high texture quality
|
| 278 |
h, w = green_band.shape[:2]
|
| 279 |
+
if h > 512 or w > 512:
|
| 280 |
+
scale = 512 / max(h, w)
|
| 281 |
green_band = cv2.resize(green_band, None, fx=scale, fy=scale, interpolation=cv2.INTER_LINEAR)
|
| 282 |
if mask is not None:
|
| 283 |
mask_resized = cv2.resize(mask, (green_band.shape[1], green_band.shape[0]), interpolation=cv2.INTER_NEAREST)
|