Can only process images which are NOT sub-images.
354140
public static void process_I8(GrayU8 orig,
								  GrayS16 derivX,
								  GrayS16 derivY) {
		final byte[] data = orig.data;
		final short[] imgX = derivX.data;
		final short[] imgY = derivY.data;

		final int width = orig.getWidth();
		final int height = orig.getHeight() - 1;

		final int adjWidth = width - 2;

		//CONCURRENT_BELOW BoofConcurrency.loopFor(1,height,y->{
		for (int y = 1; y < height; y++) {
			int endX_alt = width * y + (width - adjWidth % 3) - 1;
			int endX = endX_alt + adjWidth % 3;

			int a11, a12, a13;
			int a21, a22, a23;
			int a31, a32, a33;

			int index = width * y + 1;

			a11 = data[index - width - 1] & 0xFF;
			a12 = data[index - width] & 0xFF;
			a21 = data[index - 1] & 0xFF;
			a22 = data[index] & 0xFF;
			a31 = data[index + width - 1] & 0xFF;
			a32 = data[index + width] & 0xFF;

			for (; index < endX_alt;) {
				a13 = data[index - width + 1] & 0xFF;
				a23 = data[index + 1] & 0xFF;
				a33 = data[index + width + 1] & 0xFF;

				int v = (a33 - a11);
				int w = (a31 - a13);

				imgY[index] = (short) ((a32 - a12) * 2 + v + w);
				imgX[index] = (short) ((a23 - a21) * 2 + v - w);

				index++;

				a11 = data[index - width + 1] & 0xFF;
				a21 = data[index + 1] & 0xFF;
				a31 = data[index + width + 1] & 0xFF;

				v = (a31 - a12);
				w = (a32 - a11);

				imgY[index] = (short) ((a33 - a13) * 2 + v + w);
				imgX[index] = (short) ((a21 - a22) * 2 + v - w);

				index++;

				a12 = data[index - width + 1] & 0xFF;
				a22 = data[index + 1] & 0xFF;
				a32 = data[index + width + 1] & 0xFF;

				v = (a32 - a13);
				w = (a33 - a12);

				imgY[index] = (short) ((a31 - a11) * 2 + v + w);
				imgX[index] = (short) ((a22 - a23) * 2 + v - w);

				index++;
			}

			for (; index < endX; index++) {
				int v = (data[index + width + 1] & 0xFF) - (data[index - width - 1] & 0xFF);
				int w = (data[index + width - 1] & 0xFF) - (data[index - width + 1] & 0xFF);

				imgY[index] = (short) (((data[index + width] & 0xFF) - (data[index - width] & 0xFF)) * 2 + v + w);

				imgX[index] = (short) (((data[index + 1] & 0xFF) - (data[index - 1] & 0xFF)) * 2 + v - w);
			}
		}
		//CONCURRENT_ABOVE });
	}
728908
def postProcess(self, images_data, new_format, new_size):
    
    if len(images_data) == 1:
      in_bytes = io.BytesIO(images_data[0])
      img = PIL.Image.open(in_bytes)
      if img.mode != "RGB":
        img = img.convert("RGB")

    else:
      # images need to be joined before further processing
      logging.getLogger("Cover").info("Joining %u images..." % (len(images_data)))
      # TODO find a way to do this losslessly for JPEG
      new_img = PIL.Image.new("RGB", self.size)
      assert(is_square(len(images_data)))
      sq = int(math.sqrt(len(images_data)))

      images_data_it = iter(images_data)
      img_sizes = {}
      for x in range(sq):
        for y in range(sq):
          current_image_data = next(images_data_it)
          img_stream = io.BytesIO(current_image_data)
          img = PIL.Image.open(img_stream)
          img_sizes[(x, y)] = img.size
          box = [0, 0]
          if x > 0:
            for px in range(x):
              box[0] += img_sizes[(px, y)][0]
          if y > 0:
            for py in range(y):
              box[1] += img_sizes[(x, py)][1]
          box.extend((box[0] + img.size[0], box[1] + img.size[1]))
          new_img.paste(img, box=tuple(box))
      img = new_img

    out_bytes = io.BytesIO()
    if new_size is not None:
      logging.getLogger("Cover").info("Resizing from %ux%u to %ux%u..." % (self.size[0], self.size[1], new_size, new_size))
      img = img.resize((new_size, new_size), PIL.Image.LANCZOS)
      # apply unsharp filter to remove resize blur (equivalent to (images/graphics)magick -unsharp 1.5x1+0.7+0.02)
      # we don't use PIL.ImageFilter.SHARPEN or PIL.ImageEnhance.Sharpness because we want precise control over
      # parameters
      unsharper = PIL.ImageFilter.UnsharpMask(radius=1.5, percent=70, threshold=5)
      img = img.filter(unsharper)
    if new_format is not None:
      logging.getLogger("Cover").info("Converting to %s..." % (new_format.name.upper()))
      target_format = new_format
    else:
      target_format = self.format
    img.save(out_bytes,
             format=target_format.name,
             quality=90,
             optimize=True)
    return out_bytes.getvalue()
799919
public void process( I left , I right , GrayF32 imageDisparity ) {
		// check inputs and initialize data structures
		InputSanityCheck.checkSameShape(left,right,imageDisparity);
		this.imageLeft = left;
		this.imageRight = right;

		w = left.width; h = left.height;

		// Compute disparity for each pixel
		for( int y = radiusY*2; y < h-radiusY*2; y++ ) {
			for( int x = radiusX*2+minDisparity; x < w-radiusX*2; x++ ) {
				// take in account image border when computing max disparity
				int max = x-Math.max(radiusX*2-1,x-score.length);

				// compute match score across all candidates
				processPixel(x, y, max);

				// select the best disparity
				imageDisparity.set(x,y,(float)selectBest(max));
			}
		}
	}
647526
def IsImage(self, filename):
		""""""
		mimetype =  mimetypes.guess_type(filename)[0]
		if not mimetype:
			return False
		return mimetype.startswith("image/")
602507
def check_image_is_4d(img, min_num_volumes=2):
    """"""

    if len(img.shape) < 4:
        raise ValueError('Input volume must be 4D!')
    elif len(img.shape) == 4:
        for dim_size in img.shape[:3]:
            if dim_size < 1:
                raise ValueError('Atleast one slice must exist in each dimension')
        if img.shape[3] < min_num_volumes:
            raise ValueError('Input volume is 4D '
                             'with less than {} volumes!'.format(min_num_volumes))
    elif len(img.shape) > 4:
        raise ValueError('Too many dimensions : more than 4.\n'
                         'Invalid shape of image : {}'.format(img.shape))

    return img
47586
public void process( ImagePyramid<T> pyramidPrev , ImagePyramid<T> pyramidCurr ) {

		InputSanityCheck.checkSameShape(pyramidPrev, pyramidCurr);

		int numLayers = pyramidPrev.getNumLayers();

		for( int i = numLayers-1; i >= 0; i-- ) {

			T prev = pyramidPrev.getLayer(i);
			T curr = pyramidCurr.getLayer(i);

			flowCurrLayer.reshape(prev.width, prev.height);

			int N = prev.width*prev.height;
			if( scores.length < N )
				scores = new float[N];
			// mark all the scores as being very large so that if it has not been processed its score
			// will be set inside of checkNeighbors.
			Arrays.fill(scores,0,N,Float.MAX_VALUE);

			int x1 = prev.width-regionRadius;
			int y1 = prev.height-regionRadius;

			if( i == numLayers-1 ) {
				// the top most layer in the pyramid has no hint
				for( int y = regionRadius; y < y1; y++ ) {
					for( int x = regionRadius; x < x1; x++ ) {
						extractTemplate(x,y,prev);
						float score = findFlow(x,y,curr,tmp);

						if( tmp.isValid() )
							checkNeighbors(x,y,tmp, flowCurrLayer,score);
						else
							flowCurrLayer.unsafe_get(x, y).markInvalid();
					}
				}
			} else {
				// for all the other layers use the hint of the previous layer to start its search
				double scale = pyramidPrev.getScale(i+1)/pyramidPrev.getScale(i);
				for( int y = regionRadius; y < y1; y++ ) {
					for( int x = regionRadius; x < x1; x++ ) {
						// grab the flow in higher level pyramid
						ImageFlow.D p = flowPrevLayer.get((int)(x/scale),(int)(y/scale));
						if( !p.isValid() )
							continue;

						// get the template around the current point in this layer
						extractTemplate(x,y,prev);

						// add the flow from the higher layer (adjusting for scale and rounding) as the start of
						// this search
						int deltaX = (int)(p.x*scale+0.5);
						int deltaY = (int)(p.y*scale+0.5);

						int startX = x + deltaX;
						int startY = y + deltaY;

						float score = findFlow(startX,startY,curr,tmp);

						// find flow only does it relative to the starting point
						tmp.x += deltaX;
						tmp.y += deltaY;

						if( tmp.isValid() )
							checkNeighbors(x,y,tmp, flowCurrLayer,score);
						else
							flowCurrLayer.unsafe_get(x,y).markInvalid();
					}
				}
			}

			// swap the flow images
			ImageFlow tmp = flowPrevLayer;
			flowPrevLayer = flowCurrLayer;
			flowCurrLayer = tmp;
		}
	}
770692
def post_process_images(self, doctree):
        """"""

        super(AbstractSlideBuilder, self).post_process_images(doctree)

        # figure out where this doctree is in relation to the srcdir
        relative_base = (
            ['..'] *
            doctree.attributes.get('source')[len(self.srcdir) + 1:].count('/')
        )

        for node in doctree.traverse(nodes.image):

            if node.get('candidates') is None:
                node['candidates'] = ('*',)

            # fix up images with absolute paths
            if node['uri'].startswith(self.outdir):
                node['uri'] = '/'.join(
                    relative_base + [
                        node['uri'][len(self.outdir) + 1:]
                    ]
                )
1128699
def recognize_byte(self, image, timeout=10):
        """"""
        result = []

        alpr = subprocess.Popen(
            self._cmd,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.DEVNULL
        )

        # send image
        try:
            # pylint: disable=unused-variable
            stdout, stderr = alpr.communicate(input=image, timeout=10)
            stdout = io.StringIO(str(stdout, 'utf-8'))
        except subprocess.TimeoutExpired:
            _LOGGER.error("Alpr process timeout!")
            alpr.kill()
            return None

        tmp_res = {}
        while True:
            line = stdout.readline()
            if not line:
                if len(tmp_res) > 0:
                    result.append(tmp_res)
                break

            new_plate = self.__re_plate.search(line)
            new_result = self.__re_result.search(line)

            # found a new plate
            if new_plate and len(tmp_res) > 0:
                result.append(tmp_res)
                tmp_res = {}
                continue

            # found plate result
            if new_result:
                try:
                    tmp_res[new_result.group(1)] = float(new_result.group(2))
                except ValueError:
                    continue

        _LOGGER.debug("Process alpr with result: %s", result)
        return result
937590
def filter(self, containers=True, images=True, stopped=True, cached=False, sort_by_created=True):
        
        content = []
        containers_o = None
        images_o = None
        # return containers when containers=False and running=True
        if containers or not stopped:
            containers_o = self.get_containers(cached=cached, stopped=stopped)
            content += containers_o.response
        if images:
            images_o = self.get_images(cached=cached)
            content += images_o.response
        if sort_by_created:
            content.sort(key=attrgetter("natural_sort_value"), reverse=True)
        return content, containers_o, images_o
584979
def processed_image(image, options = {})
      size = options[:size]
      upsample = !!options[:upsample]

      return image unless size.present? && has_convertible_format?

      if options[:crop]
        crop(size, options[:crop_from], options[:crop_size], upsample)
      else
        resize(size, upsample)
      end
    end
1089534
def non_object_image
      image = list_item.image

      return image.file.url if image.respond_to?(:file)
      return image if image.present?

      fallback_image
    end
1248130
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'images_processed' in _dict:
            args['images_processed'] = _dict.get('images_processed')
        else:
            raise ValueError(
                'Required property \'images_processed\' not present in DetectedFaces JSON'
            )
        if 'images' in _dict:
            args['images'] = [
                ImageWithFaces._from_dict(x) for x in (_dict.get('images'))
            ]
        else:
            raise ValueError(
                'Required property \'images\' not present in DetectedFaces JSON'
            )
        if 'warnings' in _dict:
            args['warnings'] = [
                WarningInfo._from_dict(x) for x in (_dict.get('warnings'))
            ]
        return cls(**args)
89095
def _ProcessImage(self, tag, wall_time, step, image):
    """"""
    event = ImageEvent(wall_time=wall_time,
                       step=step,
                       encoded_image_string=image.encoded_image_string,
                       width=image.width,
                       height=image.height)
    self.images.AddItem(tag, event)
518808
function (images) {
    var processed = [];
    for (var i = 0; i < images.length; i++) {
      if (typeof images[i] === 'string') {
        processed.push({url: images[i]});
      }
      else if ($.isArray(images[i])) {
        processed.push(processImagesArray(images[i]));
      }
      else {
        processed.push(processOptions(images[i]));
      }
    }
    return processed;
  }
417211
private void processFullNameINodes(DataInputStream in, ImageVisitor v,
       long numInodes, boolean skipBlocks) throws IOException {
     for(long i = 0; i < numInodes; i++) {
       processINode(in, v, skipBlocks, null);
     }
   }
154037
def _convert_images(self):
        
        self._plain_images = []
        self._colour_map = []
        for image in self._images:
            colour_map = []
            new_image = []
            for line in image.split("\n"):
                new_line = ""
                attributes = (None, None, None)
                colours = []
                while len(line) > 0:
                    match = self._colour_sequence.match(line)
                    if match is None:
                        new_line += line[0]
                        colours.append(attributes)
                        line = line[1:]
                    else:
                        # The regexp either matches:
                        # - 2,3,4 for ${c,a,b}
                        # - 5,6 for ${c,a}
                        # - 7 for ${c}.
                        if match.group(2) is not None:
                            attributes = (int(match.group(2)),
                                          ATTRIBUTES[match.group(3)],
                                          int(match.group(4)))
                        elif match.group(5) is not None:
                            attributes = (int(match.group(5)),
                                          ATTRIBUTES[match.group(6)],
                                          None)
                        else:
                            attributes = (int(match.group(7)), 0, None)
                        line = match.group(8)
                new_image.append(new_line)
                colour_map.append(colours)
            self._plain_images.append(new_image)
            self._colour_map.append(colour_map)
150100
private void processBlocks(DataInputStream in, ImageVisitor v,
      int numBlocks, boolean skipBlocks) throws IOException {
    v.visitEnclosingElement(ImageElement.BLOCKS,
                            ImageElement.NUM_BLOCKS, numBlocks);
    
    // directory or symlink, no blocks to process    
    if(numBlocks == -1 || numBlocks == -2) { 
      v.leaveEnclosingElement(); // Blocks
      return;
    }
    
    if(skipBlocks) {
      int fieldsBytes = Long.SIZE * 3;
      if (LayoutVersion.supports(Feature.BLOCK_CHECKSUM, imageVersion)) {
        // For block checksum
        fieldsBytes += Integer.SIZE;
      }
      
      int bytesToSkip = ((fieldsBytes /* fields */) / 8 /*bits*/) * numBlocks;
      if(in.skipBytes(bytesToSkip) != bytesToSkip)
        throw new IOException("Error skipping over blocks");
      
    } else {
      for(int j = 0; j < numBlocks; j++) {
        v.visitEnclosingElement(ImageElement.BLOCK);
        v.visit(ImageElement.BLOCK_ID, in.readLong());
        v.visit(ImageElement.NUM_BYTES, in.readLong());
        v.visit(ImageElement.GENERATION_STAMP, in.readLong());
        if (LayoutVersion.supports(Feature.BLOCK_CHECKSUM, imageVersion)) {
          v.visit(ImageElement.BLOCK_CHECKSUM, in.readInt());
        }
        v.leaveEnclosingElement(); // Block
      }
    }
    v.leaveEnclosingElement(); // Blocks
  }