Skip to content

Commit

Permalink
Well-Known Text Plugins: move to own package
Browse files Browse the repository at this point in the history
Renamed plugins to better describe their function.
Also re-organized imports.
  • Loading branch information
imagejan committed Apr 20, 2021
1 parent 890f6d1 commit 66e1a29
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
package ch.fmi;
package ch.fmi.wkt;

import net.imagej.ops.OpService;
import net.imagej.ops.Ops;
Expand All @@ -36,11 +36,13 @@
import org.scijava.plugin.Plugin;

/**
* Plug-in to convert a 2D binary mask to a polygon geometry serialized
* to well-known text (wkt)
* Plug-in to convert a 2D binary mask image to a polygon geometry serialized to
* well-known text (wkt)
*
* @author Charismatic Claire
*/
@Plugin(type = Command.class, headless = true, menuPath = "FMI>2D Binary Mask To Text")
public class ContourPolygonBitmaskToText extends ContextCommand {
@Plugin(type = Command.class, headless = true, menuPath = "FMI>2D Binary Mask to Well-Known Text (WKT)")
public class BitmaskToWellKnownText extends ContextCommand {

@Parameter
private OpService opService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
package ch.fmi;
package ch.fmi.wkt;

import net.imglib2.*;
import net.imglib2.FinalInterval;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.RealLocalizable;
import net.imglib2.RealPoint;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.converter.Converters;
import net.imglib2.img.ImgView;
import net.imglib2.img.array.ArrayImgFactory;
import net.imglib2.roi.Masks;
import net.imglib2.roi.geom.GeomMasks;
import net.imglib2.roi.geom.real.Polygon2D;
Expand All @@ -51,11 +54,13 @@
import java.util.stream.Collectors;

/**
* Plug-in to convert a polygon geometry represented in well-known text (wkt)
* to a 2D binary mask
* Plug-in to convert a polygon geometry represented in well-known text (wkt) to
* a 2D binary mask image
*
* @author Charismatic Claire
*/
@Plugin(type = Command.class, headless = true, menuPath = "FMI>Text To 2D Binary Mask")
public class ContourPolygonTextToBitmask extends ContextCommand {
@Plugin(type = Command.class, headless = true, menuPath = "FMI>Well-Known Text (WKT) to 2D Binary Mask")
public class WellKnownTextToBitmask extends ContextCommand {

@Parameter
private LogService logService;
Expand Down Expand Up @@ -97,16 +102,16 @@ public void run() {
// create image
RandomAccessibleInterval<BitType> interval = Converters.convert(
(RandomAccessibleInterval<BoolType>) view, (in, out) -> out.set(in.get()), new BitType());
Img<BitType> image = new ImgView<>(interval, new ArrayImgFactory<>());
Img<BitType> image = ImgView.wrap(interval);
// return result
output = image;
} catch (ParseException e) {
logService.error(String.format("Could not create a polygon from input <%s>", text), e);
} catch(IllegalArgumentException e) {
logService.error(
String.format("Could not define bounding box of polygon derived from input <%s>", text), e);
} catch(Exception e) {
logService.error(String.format("Something went wrong for input <%s>", text), e);
// } catch(Exception e) {
// logService.error(String.format("Something went wrong for input <%s>", text), e);
}
}

Expand Down

0 comments on commit 66e1a29

Please sign in to comment.