def scale(ip, s):
	""" Scale the image with the parameter scale = s """
	imp = ImagePlus('scale',ip)
	IJ.run(imp, "Scale...", "x="+str(s)+" y="+str(s)+" interpolation=Bilinear average");
	ip = imp.getProcessor()
	w = ip.width
	h = ip.height
	cd = CanvasResizer()
	ip = cd.expandImage(ip, int(round(s*w)), int(round(s*h)), -int(round((1-s)/2*w)), -int(round((1-s)/2*h)) )
	return ip
def scaleLongSide(ip, longSide):
	""" Scale the image with respect to the longSide parameter (new size along the long side of the image should equal the longSide parameter) """
	w = ip.width
	h = ip.height
	l = max(w,h)
	s = float(longSide)/l
	imp = ImagePlus('scaleLongSide',ip)
	IJ.run(imp, "Scale...", "x="+str(s)+" y="+str(s)+" interpolation=Bilinear average");
	ip = imp.getProcessor()
	cd = CanvasResizer()
	ip = cd.expandImage(ip, int(round(s*w)), int(round(s*h)), -int(round((1-s)/2*w)), -int(round((1-s)/2*h)) )
	return ip, s
Exemplo n.º 3
0
def scale(ip, s):
    """ Scale the image with the parameter scale = s """
    imp = ImagePlus('scale', ip)
    IJ.run(imp, "Scale...",
           "x=" + str(s) + " y=" + str(s) + " interpolation=Bilinear average")
    ip = imp.getProcessor()
    w = ip.width
    h = ip.height
    cd = CanvasResizer()
    ip = cd.expandImage(ip, int(round(s * w)), int(round(s * h)),
                        -int(round(
                            (1 - s) / 2 * w)), -int(round((1 - s) / 2 * h)))
    return ip
Exemplo n.º 4
0
def scaleLongSide(ip, longSide):
    """ Scale the image with respect to the longSide parameter (new size along the long side of the image should equal the longSide parameter) """
    w = ip.width
    h = ip.height
    l = max(w, h)
    s = float(longSide) / l
    imp = ImagePlus('scaleLongSide', ip)
    IJ.run(imp, "Scale...",
           "x=" + str(s) + " y=" + str(s) + " interpolation=Bilinear average")
    ip = imp.getProcessor()
    cd = CanvasResizer()
    ip = cd.expandImage(ip, int(round(s * w)), int(round(s * h)),
                        -int(round(
                            (1 - s) / 2 * w)), -int(round((1 - s) / 2 * h)))
    return ip, s