Skip to content

how to draw 16 bits image color gray ? #3

Description

@nghiaphamsg
  • The image on the left is drawn from the function imageFromPixels(size:pixels:width:height:) in the file DicomImage.swift
  • The image on the right is using the ImageJ tool to open it.

You can also see the color difference between the two pictures.
After I investigate on google it may be necessary to set the bitmapInfo parameter to set the correct color ? Do you have any solution for the above problem?

    if let cgim = CGImage(
        width: width,
        height: height,
        bitsPerComponent: self.bitsAllocated,//self.bitsStored,
        bitsPerPixel: self.bitsAllocated,
        bytesPerRow: self.bytesPerRow, // -> bytes not bits
        space: self.colorSpace,
        bitmapInfo: bitmapInfo,
        provider: providerRef!,
        decode: nil,
        shouldInterpolate: true,
        intent: .defaultIntent
    ) {
        return cgim
    }

Data: Resources/DICOM/MR_ImplicitVRLittleEndian_MULTI_MONOCHROME2_Philips_RTNC1_33.dcm

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions