def test_RescaleIntensity(): image = skimage.data.camera() with Pipeline() as pipeline: result = RescaleIntensity(image, in_range=(0, 200), dtype=np.uint8) pipeline.run()
name = Call(lambda p: os.path.splitext(os.path.basename(p))[0], abs_path) # Read image img = ImageReader(abs_path) # Show progress bar for frames #TQDM(Format("Frame {name}", name=name)) # Apply running median to approximate the background image flat_field = RunningMedian(img, 5) # Correct image img = img / flat_field # Rescale intensities and convert to uint8 to speed up calculations img = RescaleIntensity(img, in_range=(0, 1.1), dtype="uint8") FilterVariables(name,img) # frame_fn = Format(os.path.join(CLEAN, "{name}.jpg"), name=name) ImageWriter(frame_fn, img) # Convert image to uint8 gray img_gray = RGB2Gray(img) # ? img_gray = Call(img_as_ubyte, img_gray) #Canny edge detection img_canny = Call(cv2.Canny, img_gray, 50,100)
from morphocut.image import ImageWriter, RescaleIntensity from morphocut.pims import BioformatsReader from morphocut.str import Format from morphocut.stream import TQDM, Slice, Pack if __name__ == "__main__": with Pipeline() as p: input_fn = "/home/moi/Work/0-Datasets/06_CD20_brightfield_6.cif" frame, series = BioformatsReader(input_fn, meta=False) # Every second frame is in fact a mask # TODO: Batch consecutive objects in the stream frame, mask = Pack(2, frame).unpack(2) image_fn = Format("/tmp/cif/{}-img.png", series) mask_fn = Format("/tmp/cif/{}-mask.png", series) frame = RescaleIntensity(frame, dtype=np.uint8) mask = RescaleIntensity(mask, dtype=np.uint8) ImageWriter(image_fn, frame) ImageWriter(mask_fn, mask) TQDM() print(p) p.run()