SMI / dicompixelanon

DICOM Pixel Anonymisation
3 stars 0 forks source link

dicom_redact - bug redacting RGB photometric #5

Closed howff closed 1 year ago

howff commented 1 year ago

It assumes that a 3-channel image is a set of monochrome frames, and that RGB is only present in multi-frame images:

        elif pixel_data.ndim == 3:
            pixel_data[frame, y0:y1, x0:x1] &= bit_mask_arr
        elif pixel_data.ndim == 4:
            pixel_data[frame, :, y0:y1, x0:x1] &= bit_mask_arr

We cannot be sure that a single-frame RGB is laid out as pixel_data[:, y0:y1, x0:x1], in fact one test has a numpy array with shape (204, 212, 3) which proves that the colour is the final channel not the first channel.

howff commented 1 year ago

Possibly fixed with https://github.com/SMI/dicompixelanon/commit/838eb1c97d316b215150f29b3b0b249a09c14c35 although it makes some assumptions which may not be correct.