WonderLandxD / opensdpc

Python library for processing whole slide images (WSIs) in sdpc format
44 stars 8 forks source link

please tell me how to obtain the macrograph image of the slice part #20

Open TakuyaHamada1964 opened 6 days ago

TakuyaHamada1964 commented 6 days ago

Thanks for your efforts, I was able to get the macrograph image of the label part using the saveLabelImg() function, but I would like to get the macrograph image of the other slice part. The GetSliceJpeg() function is registered in the library, and I tried calling it in the same way as the saveLabelImg() function, but I was unable to obtain the macrograph image. Could you please tell me how to obtain the macrograph image of the slice part?

lingxitong commented 6 days ago

Thank you for your attention to the repository. May I ask if your requirement is to read the thumbnail of the WSI?

TakuyaHamada1964 commented 6 days ago

No, slice part of the macrograph image. This is the red part of the attached image. sample

lingxitong commented 4 days ago

Can you show me your code?

TakuyaHamada1964 commented 2 days ago

... so.GetLabelJpeg.argtypes = [POINTER(SqSdpcInfo), POINTER(c_uint), POINTER(c_uint), POINTER(c_size_t)] so.GetLabelJpeg.restype = POINTER(c_uint8) so.GetSliceJpeg.argtypes = [POINTER(SqSdpcInfo), POINTER(c_uint), POINTER(c_uint), POINTER(c_size_t)] so.GetSliceJpeg.restype = POINTER(c_uint8) so.GetRoiSliceJpeg.argtypes = [POINTER(SqSdpcInfo), POINTER(c_uint), POINTER(c_uint), POINTER(c_size_t)] so.GetRoiSliceJpeg.restype = POINTER(c_uint8) so.GetThumbnailJpeg.argtypes = [POINTER(SqSdpcInfo), POINTER(c_uint), POINTER(c_uint), POINTER(c_size_t)] so.GetThumbnailJpeg.restype = POINTER(c_uint8)

class OldSdpc: def init(self, sdpcPath): self.sdpcPath = sdpcPath self.sdpc = self.readSdpc(self.sdpcPath) self.level_count = self.getLevelCount() self.level_downsamples = self.getLevelDownsamples() self.level_dimensions = self.getLevelDimensions() self.scan_magnification = self.readSdpc(self.sdpcPath).contents.picHead.contents.rate self.sampling_rate = self.readSdpc(self.sdpcPath).contents.picHead.contents.scale

def saveLabelImg(self, save_path):
    wPos = POINTER(c_uint)(c_uint(0))
    hPos = POINTER(c_uint)(c_uint(0))
    sizePos = POINTER(c_size_t)(c_size_t(0))
    rgb_pos = so.GetLabelJpeg(self.sdpc, wPos, hPos, sizePos)
    with open(save_path, 'bw') as f:
        buf = bytearray(rgb_pos[:sizePos.contents.value])
        f.write(buf)
    f.close()

def saveSliceImg(self, save_path):
    wPos = POINTER(c_uint)(c_uint(0))
    hPos = POINTER(c_uint)(c_uint(0))
    sizePos = POINTER(c_size_t)(c_size_t(0))
    rgb_pos = so.GetSliceJpeg(self.sdpc, wPos, hPos, sizePos)
    with open(save_path, 'bw') as f:
        buf = bytearray(rgb_pos[:sizePos.contents.value])
        f.write(buf)
    f.close()

def saveRoiSliceImg(self, save_path):
    wPos = POINTER(c_uint)(c_uint(0))
    hPos = POINTER(c_uint)(c_uint(0))
    sizePos = POINTER(c_size_t)(c_size_t(0))
    rgb_pos = so.GetRoiSliceJpeg(self.sdpc, wPos, hPos, sizePos)
    with open(save_path, 'bw') as f:
        buf = bytearray(rgb_pos[:sizePos.contents.value])
        f.write(buf)
    f.close()

def saveThumbnailImg(self, save_path):
    wPos = POINTER(c_uint)(c_uint(0))
    hPos = POINTER(c_uint)(c_uint(0))
    sizePos = POINTER(c_size_t)(c_size_t(0))
    rgb_pos = so.GetThumbnailJpeg(self.sdpc, wPos, hPos, sizePos)
    with open(save_path, 'bw') as f:
        buf = bytearray(rgb_pos[:sizePos.contents.value])
        f.write(buf)
    f.close()
TakuyaHamada1964 commented 2 days ago

saveLabelImg() function, saveThumbnailImg() function worked fine (saveThumbnailImg() function is different from the image I wanted), but saveSliceImg() function and saveRoiSliceImg() function are wPos = hPos = sizePos = rgb_pos = 0. , it didn't work well.