Commit 4937e60f authored by gonciarz's avatar gonciarz
Browse files

Fix for 'zooming' from Trajectories output window in text mode of Particle Tracker

parent 474e8a79
......@@ -131,13 +131,16 @@ public class MosaicUtils {
crs.next();
// Get the min and max
T min = crs.get().createVariable();
T max = crs.get().createVariable();
getMinMax(crs, min, max);
// min/max values has not much sense with RGB types
if (!(data instanceof ARGBType)) {
// Get the min and max
T min = crs.get().createVariable();
T max = crs.get().createVariable();
getMinMax(crs, min, max);
// get conversion;
conv.setMinMax(min.getRealDouble(), max.getRealDouble());
// get conversion;
conv.setMinMax(min.getRealDouble(), max.getRealDouble());
}
return conv;
}
......
......@@ -158,9 +158,9 @@ public class TrajectoryStackWin extends StackWindow implements MouseListener {
int newY = Math.max(0, bounds.y - size);
int newWidth = bounds.width + 2*size;
if (newX + newWidth > img.getWidth()) newWidth = img.getWidth() - newX;
if (newX + newWidth >= img.getWidth()) newWidth = img.getWidth() - newX;
int newHeight = bounds.height + 2*size;
if (newY + newHeight > img.getHeight()) newHeight = img.getHeight() - newY;
if (newY + newHeight >= img.getHeight()) newHeight = img.getHeight() - newY;
return new Roi(newX, newY, newWidth, newHeight);
}
......
......@@ -21,6 +21,7 @@ import java.util.Vector;
import javax.swing.JLabel;
import mosaic.utils.ImgUtils;
import org.apache.log4j.Logger;
import ij.IJ;
......@@ -912,15 +913,24 @@ public class ParticleTracker3DModular_ implements PlugInFilter, PreviewInterface
final Trajectory traj = (iTrajectories.elementAt(trajectory_index));
final Rectangle r = area.getBounds();
if (iInputImage == null) {
IJ.showStatus("Creating image from particles and trajectories ...");
final Img<ARGBType> iw = createHyperStackFromFrames();
if (iw != null) {
iInputImage = ImageJFunctions.wrap(iw, "Video");
}
}
// Create a cropped rescaled image
final Img<UnsignedByteType> img = ImagePlusAdapter.wrap(iInputImage);
final long min[] = new long[img.numDimensions()];
final long max[] = new long[img.numDimensions()];
min[0] = r.x;
max[0] = r.x + r.width;
max[0] = r.x + r.width - 1;
min[1] = r.y;
max[1] = r.y + r.height;
max[1] = r.y + r.height - 1;
for (int i = 2; i < img.numDimensions() - 1; i++) {
min[i] = 0;
max[i] = img.dimension(i);
......
......@@ -14,7 +14,10 @@ import ij.process.ImageProcessor;
import ij.process.StackStatistics;
import mosaic.utils.ArrayOps.MinMax;
import mosaic.utils.math.Matrix;
import net.imglib2.RandomAccess;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.type.numeric.NumericType;
import net.imglib2.type.numeric.RealType;
public class ImgUtils {
......@@ -143,7 +146,7 @@ public class ImgUtils {
/**
* Creates 3D [z][x][y] binary (boolean) array from provided ImagePlus
* @param aImage input image
* @param aInputImage input image
* @return generated array with false for values == 0 and true otherwise
*/
public static boolean[][][] imgToZXYbinaryArray(ImagePlus aInputImage) {
......@@ -271,7 +274,7 @@ public class ImgUtils {
* bottom row(s)) are padded with neighbors values.
*
* @param aInputImg Original image array
* @param aNewImgArray Resized image array (must be created by user)
* @param aOutputImg Resized image array (must be created by user)
*/
static void imgResize(float[][] aInputImg, float[][] aOutputImg) {
final int w = aInputImg[0].length;
......@@ -300,7 +303,7 @@ public class ImgUtils {
* bottom row(s)) are padded with neighbors values.
*
* @param aInputImg Original image array
* @param aNewImgArray Resized image array (must be created by user)
* @param aOutputImg Resized image array (must be created by user)
*/
static public void imgResize(double[][] aInputImg, double[][] aOutputImg) {
final int w = aInputImg[0].length;
......@@ -331,7 +334,7 @@ public class ImgUtils {
* @param aTitle - title for newly generated image
* @param aXscale - scale for x dim
* @param aYscale - scale for y dim
* @param convertToRgb - should output ImagePlus be RGB regardless of input?
* @param aType - should output ImagePlus be RGB regardless of input?
* @return
*/
static public ImagePlus createNewEmptyImgPlus(final ImagePlus aOrigIp, String aTitle, double aXscale, double aYscale, OutputType aType) {
......@@ -520,7 +523,22 @@ public class ImgUtils {
str += img1.dimension(i) + ((i == numDimensions - 1) ? "" : "/");
return str;
}
/**
* @return String with information of provided image (dimensions/type/bitdepth)
*/
public static <T extends NumericType< T >> String getImageInfo(RandomAccessibleInterval<T> img1) {
long[] dims = img1.dimensionsAsLongArray();
for (int i = 0; i < dims.length; ++i) dims[i] = 0;
String str = "Type: " + img1.getAt(dims).getClass().getName();
str += " ElementString: " + img1.getAt(dims).toString();
str += " Dims:";
int numDimensions = img1.numDimensions();
for (int i = 0; i < numDimensions; ++i)
str += img1.dimension(i) + ((i == numDimensions - 1) ? "" : "/");
return str;
}
/**
* Runs distance transform on provided image (this image will be changed)
* @param aImage input image
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment