If an image is to be created then the generic type can't be used a specific one needs to be.  An arbitrary
specific image type is returned here.
338680
public static <T> T convertGenericToSpecificType(Class<?> type) {
		if (type == GrayI8.class)
			return (T) GrayU8.class;
		if (type == GrayI16.class)
			return (T) GrayS16.class;
		if (type == InterleavedI8.class)
			return (T) InterleavedU8.class;
		if (type == InterleavedI16.class)
			return (T) InterleavedS16.class;
		return (T) type;
	}
1124658
def set_image(self, image = None):
        
        
        if image is None or type(image) is not int:
            raise KPError("Need a new image number")
        else:
            self.image = image
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
1332033
public void setImage(T image ) {
		match.setInputImage(image);
		this.imageWidth = image.width;
		this.imageHeight = image.height;
	}
742163
def set_image(self, img):
        ''''''
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            if hasattr(img, 'shape'):
                (width, height) = (img.shape[1], img.shape[0])
                self._bmp = wx.BitmapFromBuffer(width, height, np.uint8(img)) # http://stackoverflow.com/a/16866833/2559632
            elif hasattr(img, 'GetHeight'):
                self._bmp = wx.BitmapFromImage(img)
            else:
                print("Unsupported image type: %s" % type(img))
                return
            self.SetMinSize((self._bmp.GetWidth(), self._bmp.GetHeight()))
795861
def get_image_by_kind(self, kind):
        
        for ss in self.images:
            if ss.kind == kind:
                return ss
        return None
755746
public static <T extends ImageGray<T>> T convertFromSingle(BufferedImage src, T dst, Class<T> type) {
		if (type == GrayU8.class) {
			return (T) convertFrom(src, (GrayU8) dst);
		} else if( GrayI16.class.isAssignableFrom(type) ) {
			return (T) convertFrom(src, (GrayI16) dst,(Class)type);
		} else if (type == GrayF32.class) {
			return (T) convertFrom(src, (GrayF32) dst);
		} else {
			throw new IllegalArgumentException("Unknown type " + type);
		}
	}
53724
public CustomEmojiBuilder setImage(BufferedImage image, String type) {
        delegate.setImage(image, type);
        return this;
    }
1049532
public static Image getScaledInstance(Image img, int targetWidth, int targetHeight) {
		final int type = BufferedImage.TYPE_INT_ARGB;
		Image ret = img;
		final int width = ret.getWidth(null);
		final int height = ret.getHeight(null);
		if (width != targetWidth && height != targetHeight) {
			// a priori plus performant que Image.getScaledInstance
			final BufferedImage scratchImage = new BufferedImage(targetWidth, targetHeight, type);
			final Graphics2D g2 = scratchImage.createGraphics();
			g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
			g2.drawImage(ret, 0, 0, targetWidth, targetHeight, 0, 0, width, height, null);
			g2.dispose();
			ret = scratchImage;
		}
		return ret;
	}
1313891
public static boolean canWrite (BufferedImage image)
    {
        return (image.getColorModel() instanceof IndexColorModel) &&
            (image.getRaster().getDataBuffer() instanceof DataBufferByte);
    }
1348228
public static <T extends GrayF<T>, W extends ImageInterleaved>
	DiscreteFourierTransform<T,W> createTransform( ImageDataType type ) {
		switch( type ) {
			case F32: return (DiscreteFourierTransform)createTransformF32();
			case F64: return (DiscreteFourierTransform)createTransformF64();
		}
		throw new IllegalArgumentException("Unsupported image type "+type);
	}
957170
public void setTo( ImageType o ) {
		this.family = o.family;
		this.dataType = o.dataType;
		this.numBands = o.numBands;
	}
1368069
public static <T extends ImageGray<T>> ImageBorder<T> singleValue(T image, double value) {
		ImageBorder border = singleValue(image.getClass(), value);
		border.setImage(image);
		return border;
	}
1077402
public static Image getInstance(Image image) {
		if (image == null)
			return null;
		try {
			Class cs = image.getClass();
			Constructor constructor = cs
					.getDeclaredConstructor(new Class[] { Image.class });
			return (Image) constructor.newInstance(new Object[] { image });
		} catch (Exception e) {
			throw new ExceptionConverter(e);
		}
	}
1315340
public Type getType() {
        int varType = image.getInt(0) & 0xFFFF;
        return EnumDictionary.get(Type.class).constant(varType);
    }
806569
public Type unboxedTypeOrType(Type t) {
        Type unboxedType = unboxedType(t);
        return unboxedType.hasTag(NONE) ? t : unboxedType;
    }
1196041
@Override
  public void validate() {
    int n = 0;
    try {
      for (TiffObject o : model.getImageIfds()) {
        IFD ifd = (IFD) o;
        IfdTags metadata = ifd.getMetadata();
        validateMetadata(metadata);
        checkImage(ifd, n, metadata);
        n++;
      }
    } catch (Exception ex) {

    }
  }
598250
public BufferedImage copyImage(BufferedImage image) {
        BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
        Graphics2D g2d = newImage.createGraphics();
        g2d.drawImage(image, 0, 0, null);
        g2d.dispose();
        return newImage;
    }