fixed bug that caused IJHyperstack.getimage to be able to modify the hyperstack instance
This commit is contained in:
parent
608fefce0a
commit
c42972736f
|
@ -30,6 +30,19 @@ PIXEL_TYPE_TO_CV_PIXEL_TYPE = {
|
||||||
PixelType.F32: opencv_core.CV_32F,
|
PixelType.F32: opencv_core.CV_32F,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def clone_processor(src_processor, clone_pixel_type):
|
||||||
|
"""
|
||||||
|
:param Processor processor:
|
||||||
|
:param PixelType clone_pixel_type:
|
||||||
|
:rtype Processor:
|
||||||
|
"""
|
||||||
|
clone_processor = {
|
||||||
|
PixelType.U8: src_processor.convertToByteProcessor(),
|
||||||
|
PixelType.U16: src_processor.convertToShortProcessor(),
|
||||||
|
PixelType.F32: src_processor.convertToFloatProcessor(),
|
||||||
|
}[clone_pixel_type]
|
||||||
|
return clone_processor
|
||||||
|
|
||||||
class IJImage(IImage):
|
class IJImage(IImage):
|
||||||
|
|
||||||
def __init__(self, image_engine, ij_image=None, width=None, height=None, pixel_type=None):
|
def __init__(self, image_engine, ij_image=None, width=None, height=None, pixel_type=None):
|
||||||
|
@ -50,17 +63,13 @@ class IJImage(IImage):
|
||||||
stack_name = ''
|
stack_name = ''
|
||||||
self.ij_image = IJ.createHyperStack(stack_name, width, height, 1, 1, 1, PixelType.get_num_bits(pixel_type))
|
self.ij_image = IJ.createHyperStack(stack_name, width, height, 1, 1, 1, PixelType.get_num_bits(pixel_type))
|
||||||
|
|
||||||
|
|
||||||
def clone(self, clone_pixel_type=None):
|
def clone(self, clone_pixel_type=None):
|
||||||
if clone_pixel_type == None:
|
if clone_pixel_type == None:
|
||||||
clone_pixel_type = self.get_pixel_type()
|
clone_pixel_type = self.get_pixel_type()
|
||||||
copy = IJImage(self.image_engine, width=self.get_width(), height=self.get_height(), pixel_type=clone_pixel_type)
|
copy = IJImage(self.image_engine, width=self.get_width(), height=self.get_height(), pixel_type=clone_pixel_type)
|
||||||
src_processor = self.ij_image.getProcessor()
|
src_processor = self.ij_image.getProcessor()
|
||||||
clone_processor = {
|
copy.ij_image.setProcessor( clone_processor(src_processor, clone_pixel_type) )
|
||||||
PixelType.U8: src_processor.convertToByteProcessor(),
|
|
||||||
PixelType.U16: src_processor.convertToShortProcessor(),
|
|
||||||
PixelType.F32: src_processor.convertToFloatProcessor(),
|
|
||||||
}[clone_pixel_type]
|
|
||||||
copy.ij_image.setProcessor( clone_processor )
|
|
||||||
assert copy.get_pixel_type() == clone_pixel_type
|
assert copy.get_pixel_type() == clone_pixel_type
|
||||||
return copy
|
return copy
|
||||||
|
|
||||||
|
@ -129,7 +138,7 @@ class IJHyperStack(IHyperStack):
|
||||||
self.hyperstack.setPositionWithoutUpdate(channel_index + 1, slice_index + 1, frame_index + 1)
|
self.hyperstack.setPositionWithoutUpdate(channel_index + 1, slice_index + 1, frame_index + 1)
|
||||||
stack_name = ''
|
stack_name = ''
|
||||||
image_plus = IJ.createHyperStack(stack_name, self.get_width(), self.get_height(), 1, 1, 1, PixelType.get_num_bits(self.get_pixel_type()))
|
image_plus = IJ.createHyperStack(stack_name, self.get_width(), self.get_height(), 1, 1, 1, PixelType.get_num_bits(self.get_pixel_type()))
|
||||||
image_plus.setProcessor(self.hyperstack.getProcessor())
|
image_plus.setProcessor(clone_processor(self.hyperstack.getProcessor(), self.get_pixel_type()))
|
||||||
ij_image = IJImage(self.image_engine, image_plus)
|
ij_image = IJImage(self.image_engine, image_plus)
|
||||||
return ij_image
|
return ij_image
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue