Transforms the image into a vector and returns the result.

@return The image's vector.
@throws Exception
771766
public double[] transformToVector() throws Exception {
		if (vectorLength > vladAggregator.getVectorLength() || vectorLength <= 0) {
			throw new Exception("Vector length should be between 1 and " + vladAggregator.getVectorLength());
		}

		// the local features are extracted
		double[][] features;
		if (image == null) { // first the image is read if the image field is null
			try { // first try reading with the default class
				image = ImageIO.read(new File(imageFolder + imageFilename));
			} catch (IllegalArgumentException e) {
				// this exception is probably thrown because of a greyscale jpeg image
				System.out.println("Exception: " + e.getMessage() + " | Image: " + imageFilename);
				// retry with the modified class
				image = ImageIOGreyScale.read(new File(imageFolder + imageFilename));
			}
		}

		// next the image is scaled
		ImageScaling scale = new ImageScaling(maxImageSizeInPixels);
		try {
			image = scale.maxPixelsScaling(image);
		} catch (Exception e) {
			throw new Exception("Exception thrown when scaling the image!\n" + e.getMessage());
		}
		// next the local features are extracted
		features = featureExtractor.extractFeatures(image);

		// next the features are aggregated
		double[] vladVector = vladAggregator.aggregate(features);

		if (vladVector.length == vectorLength) {
			// no projection is needed
			return vladVector;
		} else {
			// pca projection is applied
			double[] projected = pcaProjector.sampleToEigenSpace(vladVector);
			return projected;
		}
	}
759504
public final BufferedImage decode() throws IOException {
		if (!validPNG) {
			return null;
		}
		ColorModel cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
		SampleModel smodel = new ComponentSampleModel(DATA_TYPE, width, height, 3, width * 3, BAND_OFFSETS);

		byte[] bytes = new byte[width * height * 3];// must new each time!
		byte[][] data = new byte[][] { bytes };
		ByteBuffer buffer = ByteBuffer.wrap(bytes);
		decode(buffer, TextureFormat.RGB);
		DataBufferByte dbuf = new DataBufferByte(data, bytes.length, OFFSET);
		WritableRaster raster = Raster.createWritableRaster(smodel, dbuf, null);

		BufferedImage bi = new BufferedImage(cmodel, raster, false, null);
		bi.flush();
		return bi;
	}
160712
public java.lang.String getImage() {
    java.lang.Object ref = image_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      image_ = s;
      return s;
    }
  }
391282
public function produce( $vector1, $vector2 )
	{
		$sum = 0;
		if( $vector1->getDimension() != $vector2->getDimension() )
			throw new Exception( 'Dimensions of Vectors are not compatible.' );

		for( $i=0; $i<$vector1->getDimension(); $i++)
			$sum += $vector1->getValueFromIndex( $i ) * $vector2->getValueFromIndex( $i );
		return $sum;
	}
961589
public function actionImageResize() {
		$source = $this->getSource();

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $source->getPath());

		$info = $this->getImageEditorInfo();

		if (!$info->box || (int)$info->box->w <= 0) {
			throw new \Exception('Width not specified', Consts::ERROR_CODE_BAD_REQUEST);
		}

		if (!$info->box || (int)$info->box->h <= 0) {
			throw new \Exception('Height not specified', Consts::ERROR_CODE_BAD_REQUEST);
		}


		$info->img
			->resize((int)$info->box->w, (int)$info->box->h)
			->save($info->path . $info->newname, $source->quality);
	}
507377
private byte[] createErrorImage(int width, int height, Exception e) throws IOException {
		String error = e.getMessage();
		if (null == error) {
			Writer result = new StringWriter();
			PrintWriter printWriter = new PrintWriter(result);
			e.printStackTrace(printWriter);
			error = result.toString();
		}

		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
		Graphics2D g = (Graphics2D) image.getGraphics();

		g.setColor(Color.RED);
		g.drawString(error, ERROR_MESSAGE_X, height / 2);

		ByteArrayOutputStream out = new ByteArrayOutputStream();
		ImageIO.write(image, "PNG", out);
		out.flush();
		byte[] result = out.toByteArray();
		out.close();

		return result;
	}
781063
public ImageDownloadResult getImageDownloadResult() throws Exception {
		Future<ImageDownloadResult> future = pool.poll();
		if (future == null) { // no completed tasks in the pool
			return null;
		} else {
			try {
				ImageDownloadResult imdr = future.get();
				return imdr;
			} catch (Exception e) {
				throw e;
			} finally {
				// in any case (Exception or not) the numPendingTask should be reduced
				numPendingTasks--;
			}
		}
	}
705392
public CifarRaw readImage() throws IOException {

    int label = readUnsignedByte(); // peel off the first byte which is the image label

    int[][] red = new int[getRows()][getCols()];
    for (int i = 0; i < getCols(); i++) {
      for (int j = 0; j < getRows(); j++) {
        red[i][j] = readUnsignedByte();
      }
    }

    int[][] green = new int[getRows()][getCols()];
    for (int i = 0; i < getCols(); i++) {
      for (int j = 0; j < getRows(); j++) {
        green[i][j] = readUnsignedByte();
      }
    }

    int[][] blue = new int[getRows()][getCols()];
    for (int i = 0; i < getCols(); i++) {
      for (int j = 0; j < getRows(); j++) {
        blue[i][j] = readUnsignedByte();
      }
    }
    return new CifarRaw(label, red, green, blue);
  }
250760
public Drawable get() {
        final Drawable[] drawables = new Drawable[]{
                mPlaceHolder,
                new BitmapDrawable(mContext.getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)),
        };

        final TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
        into(new Callback() {
            @Override
            public void onBitmapLoaded(String path, Bitmap bitmap) {
                Log.d(TAG, "callback " + path + " called");
                if (bitmap != null) {
                    Log.d(TAG, "bitmap " + path + " loaded");

                    Drawable drawable = drawables[1];
                    if (drawable != null && drawable instanceof BitmapDrawable) {
                        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawables[1];

                        try {
                            Method method = BitmapDrawable.class.getDeclaredMethod("setBitmap", Bitmap.class);
                            method.setAccessible(true);
                            method.invoke(bitmapDrawable, bitmap);

                            Log.d(TAG, "bitmap " + path + " added to transition");

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }

                    transitionDrawable.startTransition(500);
                    Log.d(TAG, "image " + path + " transition started");
                }

            }
        });

        return transitionDrawable;
    }
707169
protected Image convertToImage(Object imageDescription) {
		if (imageDescription instanceof Image) {
			return (Image) imageDescription;
		} else if (imageDescription instanceof ImageDescriptor) {
			return this.imageHelper.getImage((ImageDescriptor) imageDescription);
		} else if (imageDescription instanceof String) {
			return this.imageHelper.getImage((String) imageDescription);
		}
		return null;
	}
755981
public int[][] readImage() throws IOException {
        int[][] dat = new int[getRows()][getCols()];
        for (int i = 0; i < getCols(); i++) {
            for (int j = 0; j < getRows(); j++) {
                dat[i][j] = readUnsignedByte();
            }
        }
        return dat;
    }
1006076
@Override
   public Image loadImage(URL image, float opacity) throws VectorPrintException {
      try {
         if (log.isLoggable(Level.FINE)) {
            log.fine(String.format("loading image from %s", String.valueOf(image)));
         }
         BufferedImage awtim = null;
         if ("file".equals(image.getProtocol())) {
            awtim = makeImageTranslucent(ImageIO.read(new File(image.getFile())), opacity);
         } else {
            awtim = makeImageTranslucent(ImageIO.read(image), opacity);
         }
         return Image.getInstance(awtim, null);
      } catch (BadElementException | IOException ex) {
         throw new VectorPrintException(String.format("unable to load image %s", image.toString()), ex);
      }
   }
510902
public Vector<Object> toValuesVector() {
		final Vector<Object> values = new Vector<Object>();
		for (final JKTableColumnValue value : this.columnsValues) {
			values.add(value);
		}
		return values;
	}
645462
public static BufferedImage getImage(byte[] imageBytes) throws IOException {

		BufferedImage image = null;

		if (imageBytes != null) {
			ByteArrayInputStream stream = new ByteArrayInputStream(imageBytes);
			image = ImageIO.read(stream);
			stream.close();
		}

		return image;
	}
627246
public String getImageRoot()
    {
        if (_imageRoot != null)
            return _imageRoot;
        if (_parent != null)
            return _parent.getImageRoot();
        return null;
    }
980348
public function getImagineImage()
    {
        if (null === $this->imagineImage) {
            $app = Application::getFacadeApplication();
            $resource = $this->getFileResource();
            $mimetype = $resource->getMimeType();
            $imageLibrary = $app->make(ImagineInterface::class);

            switch ($mimetype) {
                case 'image/svg+xml':
                case 'image/svg-xml':
                case 'text/plain':
                    if ($imageLibrary instanceof \Imagine\Gd\Imagine) {
                        try {
                            $imageLibrary = $app->make('image/imagick');
                        } catch (Exception $x) {
                            $this->imagineImage = false;
                        } catch (Throwable $x) {
                            $this->imagineImage = false;
                        }
                    }
                    break;
            }

            if (null === $this->imagineImage) {
                $metadataReader = $imageLibrary->getMetadataReader();
                if (!$metadataReader instanceof ExifMetadataReader) {
                    if ($app->make('config')->get('concrete.file_manager.images.use_exif_data_to_rotate_images')) {
                        try {
                            $imageLibrary->setMetadataReader(new ExifMetadataReader());
                        } catch (NotSupportedException $e) {
                        }
                    }
                }
                try {
                    $this->imagineImage = $imageLibrary->load($resource->read());
                } catch (FileNotFoundException $e) {
                    $this->imagineImage = false;
                }
            }
        }

        return $this->imagineImage ?: null;
    }
584780
public static <I extends ImageGray<I>, T extends ImageGray>
	T transform( I input , T transformed ) {
		if( input instanceof GrayF32) {
			return (T)IntegralImageOps.transform((GrayF32)input,(GrayF32)transformed);
		} else if( input instanceof GrayF64) {
			return (T)IntegralImageOps.transform((GrayF64)input,(GrayF64)transformed);
		} else if( input instanceof GrayU8) {
			return (T)IntegralImageOps.transform((GrayU8)input,(GrayS32)transformed);
		} else if( input instanceof GrayS32) {
			return (T)IntegralImageOps.transform((GrayS32)input,(GrayS32)transformed);
		} else if( input instanceof GrayS64) {
			return (T)IntegralImageOps.transform((GrayS64)input,(GrayS64)transformed);
		} else {
			throw new IllegalArgumentException("Unknown input type: "+input.getClass().getSimpleName());
		}
	}