Java Code Examples for net.imglib2.type.logic.BitType#setOne()

The following examples show how to use net.imglib2.type.logic.BitType#setOne() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WatershedTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void testWithoutMask(final RandomAccessibleInterval<FloatType> in) {
	// create mask which is 1 everywhere
	long[] dims = new long[in.numDimensions()];
	in.dimensions(dims);
	Img<BitType> mask = ArrayImgs.bits(dims);
	for (BitType b : mask) {
		b.setOne();
	}

	/*
	 * use 8-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, true,
			false);

	assertResults(in, out, mask, true, false, false);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out2 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, true,
			true);

	assertResults(in, out2, mask, true, true, false);

	/*
	 * use 4-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out3 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, false,
			false);

	assertResults(in, out3, mask, false, false, false);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out4 = (ImgLabeling<Integer, IntType>) ops.run(Watershed.class, null, in, false,
			true);

	assertResults(in, out4, mask, false, true, false);
}
 
Example 2
Source File: WatershedSeededTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void testWithoutMask(final RandomAccessibleInterval<FloatType> in,
		final ImgLabeling<Integer, IntType> seeds) {
	// create mask which is 1 everywhere
	long[] dims = new long[in.numDimensions()];
	in.dimensions(dims);
	Img<BitType> mask = ArrayImgs.bits(dims);
	for (BitType b : mask) {
		b.setOne();
	}

	/*
	 * use 8-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out = (ImgLabeling<Integer, IntType>) ops.run(WatershedSeeded.class, null, in,
			seeds, true, false);

	assertResults(in, out, seeds, mask, false, false);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out2 = (ImgLabeling<Integer, IntType>) ops.run(WatershedSeeded.class, null, in,
			seeds, true, true);

	assertResults(in, out2, seeds, mask, true, false);

	/*
	 * use 4-connected neighborhood
	 */
	// compute result without watersheds
	ImgLabeling<Integer, IntType> out3 = (ImgLabeling<Integer, IntType>) ops.run(WatershedSeeded.class, null, in,
			seeds, false, false);

	assertResults(in, out3, seeds, mask, false, false);

	// compute result with watersheds
	ImgLabeling<Integer, IntType> out4 = (ImgLabeling<Integer, IntType>) ops.run(WatershedSeeded.class, null, in,
			seeds, false, true);

	assertResults(in, out4, seeds, mask, true, false);
}