MATLAB Image Segmentation Algorithm Gives Empty Images in Julia?

matividalg
Fri, 01 Nov 2024 21:39:36 +0000
General Usage

Hi there! I’m using the DICOM, FileIO, ImageMagick and other packages to load DICOM images for segmentation, but I just seem unable to. I’ve checked every post and even the repo. This is my code:

using DICOM, Gtk4, ImageView, ImageMagick, Images, FileIO

filename = open_dialog("Choose a valid DICOM folder", select_folder = true)
data_array = dcmdir_parse(filename)
pixel_array = []

for i in range(1, size(data_array, 1))
    push!(pixel_array, (data_array[i])[(0x7FE0, 0x0010)][2])
end

for i in range(1, size(data_array, 1))
    filenamesave = raw"filedir" * string(i) *".png"
    FileIO.save(filenamesave, ImageMagick.load(IOBuffer(data_array[i][(0x7FE0, 0x0010)][2])))
end

Yes, this generates about 600 images in a folder, all black. Which is weird for me, as I have opened the dataset in MATLAB and it worked just fine. Does anyone have a clue on what could be happening? The JPEG2000 conversion is handled by ImageMagick.

ImageMagick.load(IOBuffer(data_array[i][(0x7FE0, 0x0010)][2]

The [2] is because the pixel values are a Vector(0, N). Basically, I’m flattening the vector so I can convert the image.

If anyone’s got a clue, I’d thank your help.
Thanks dearly,
Mati.

8 posts - 3 participants