diff --git a/docs/changelog.md b/docs/changelog.md index 820a7f1..fa2561f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,27 @@ ## Changelog All notable changes to this project will be documented below. + +#### annotate.get_centroids + +* v0.1dev: coords_list = **annotate.get_centroids**(*bin_img*) + +#### annotate.napari_classes + +* v0.1dev: class_list = **annotate.napari_classes**(*viewer*) + +#### annotate.napari_join_labels + +* v0.1dev: relabeled_mask, mask_dict = **annotate.napari_join_labels**(*img, viewer*) + +#### annotate.napari_label_classes + +* v0.1dev: viewer = **annotate.napari_label_classes**(*img, classes, show=True*) + +#### annotate.napari_open + +* v0.1dev: viewer = **annotate.napari_open**(*img, mode = 'native', show=True*) + +#### annotate.Points + +* v0.1dev: viewer = **annotate.Points**(*img, figsize=(12,6), label="dafault"*) diff --git a/docs/napari_open.md b/docs/napari_open.md index c699a85..395cc98 100644 --- a/docs/napari_open.md +++ b/docs/napari_open.md @@ -1,13 +1,14 @@ ## Open Image with Napari -Open image data (e.g. RGB, gray, hyperspectral) with an interactive Napari viewer. If a gray image is opened, the image will be pseudocolored for better visualization. +Open image data (e.g. RGB, gray, hyperspectral) with an interactive Napari viewer. Labeled masks may be colorized for better visualization. -**plantcv.annotate.napari_open**(*img, show=True*) +**plantcv.annotate.napari_open**(*img, mode='native', show=True*) **returns** napari viewer object - **Parameters:** - - img - image data (compatible with gray, RGB, and hyperspectral data. If data is hyperspecral it should be the array e.g. hyperspectral.array_data) + - img - image data (compatible with gray, RGB, and hyperspectral data. If data is hyperspecral it should be the array e.g. `hyperspectral.array_data`) + - mode - 'native' or 'colorize'. If 'colorized' is selected gray images will be colorized. - show - if show = True, viewer is launched. False setting is useful for test purposes. - **Context:** @@ -24,7 +25,7 @@ import plantcv.annotate as pcvan # Create an instance of the Points class img, path, name = pcv.readimage("./grayimg.png") -viewer = pcvan.napari_open(img=img) +viewer = pcvan.napari_open(img=img, mode='colorize') # Should open interactive napari viewer diff --git a/plantcv/annotate/napari_open.py b/plantcv/annotate/napari_open.py index 59fa317..a229e50 100755 --- a/plantcv/annotate/napari_open.py +++ b/plantcv/annotate/napari_open.py @@ -6,25 +6,26 @@ import napari -def napari_open(img, show=True): - """ - open img in napari +def napari_open(img, mode='native', show=True): + """Open an image with a napari interactive viewer - Inputs: - img = img (grayimg, rgbimg, or hyperspectral image array data e.g. - hyperspectraldata.array_data) - show = if show is True the viewer is launched. This option is useful for + Parameters + ---------- + img : numpy.ndarray + Image to be opened, img can be gray, rgb, or multispectral + mode: str + Viewing mode, either 'native' (default) or 'colorize' + show: bool + if show is True the viewer is launched. This option is useful for running tests without triggering the viewer. - Returns: - viewer = napari viewer object - - :param img: numpy.ndarray - :return viewer: napari viewer object - + Returns + ------- + napari.viewer.Viewer + Napari viewer object """ shape = np.shape(img) - if len(shape) == 2: + if len(shape) == 2 and mode == 'colorize': colorful = label2rgb(img) img = (255*colorful).astype(np.uint8) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) diff --git a/tests/test_napari_open.py b/tests/test_napari_open.py index 602e3ef..c6d1376 100644 --- a/tests/test_napari_open.py +++ b/tests/test_napari_open.py @@ -29,6 +29,19 @@ def test_napari_open_gray(test_data): viewer.close() +def test_napari_open_gray1(test_data): + """Test for PlantCV.Annotate""" + # Read in test data + img, _, _ = readimage(test_data.kmeans_seed_gray_img) + viewer = napari_open(img, mode='colorize', show=False) + coor = [(25, 25), (50, 50)] + viewer.add_points(np.array(coor), symbol="o", name="total", + face_color="red", size=1) + + assert len(viewer.layers['total'].data) == 2 + viewer.close() + + def test_napari_open_envi(test_data): """Test for PlantCV.Annotate""" # Read in test data