-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation
Description
Hi,
I’m working with RGB histology images, specifically H&E-stained images with size 256x256 from the Conic and Pannuke datasets, and would like to verify if the preprocessing function below is appropriate for using the model with the function segment_cellular_image:
def process_image_array(image_array):
# Ensure input is float32 for calculations
img = image_array.astype(np.float32)
# Get original size
h, w, _ = img.shape
desired_size = 512
# Compute average across channels before normalization
avg = image_array.mean(axis=2)
# Normalize average to [0, 1] using min-max scaling
avg_normalized = (avg - avg.min()) / (avg.max() - avg.min() + 1e-8)
# Create output RGB image with only blue channel set
output = np.zeros((*avg_normalized.shape, 3), dtype=np.float32)
output[..., 2] = avg_normalized
# Pad to 512x512 (centered padding)
h_new, w_new = output.shape[:2]
pad_h = max(0, desired_size - h_new)
pad_w = max(0, desired_size - w_new)
pad_top = pad_h // 2
pad_bottom = pad_h - pad_top
pad_left = pad_w // 2
pad_right = pad_w - pad_left
output_padded = np.pad(
output,
((pad_top, pad_bottom), (pad_left, pad_right), (0, 0)),
mode='constant',
constant_values=0
)
# Convert to (3, 512, 512)
output_ch_first = np.transpose(output_padded, (2, 0, 1))
return output_ch_first
In summary, I am:
- Converting the input RGB image to float32.
- Computing the average intensity across RGB channels.
- Min-max normalizing the average to the [0, 1] range.
- Creating an output RGB image where only the blue channel is set to the normalized average.
- Padding the image (centered) to 512×512 if necessary.
- Returning the final image in (3, 512, 512) channel-first format for model input.
I’d appreciate any feedback on whether this pipeline is suitable for RGB, particularly H&E-stained, histology images since I am not getting good segmentation results. The pipeline is modeled upon the instructions given in the paper.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation