if( input instanceof ImageGray) { if (GrayU8.class == input.getClass()) { PixelMath.plus((GrayU8) input, (int) value, (GrayU8) output); } else if (GrayS8.class == input.getClass()) { PixelMath.plus((GrayS8) input, (int) value, (GrayS8) output); } else if (GrayU16.class == input.getClass()) { PixelMath.plus((GrayU16) input, (int) value, (GrayU16) output); } else if (GrayS16.class == input.getClass()) { PixelMath.plus((GrayS16) input, (int) value, (GrayS16) output); } else if (GrayS32.class == input.getClass()) { PixelMath.plus((GrayS32) input, (int) value, (GrayS32) output); } else if (GrayS64.class == input.getClass()) { PixelMath.plus((GrayS64) input, (long) value, (GrayS64) output); } else if (GrayF32.class == input.getClass()) { PixelMath.plus((GrayF32) input, (float) value, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.plus((GrayF64) input, value, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); PixelMath.plus((InterleavedU8) input, (int) value, (InterleavedU8) output); } else if (InterleavedS8.class == input.getClass()) { PixelMath.plus((InterleavedS8) input, (int) value, (InterleavedS8) output); } else if (InterleavedU16.class == input.getClass()) { PixelMath.plus((InterleavedU16) input, (int) value, (InterleavedU16) output); } else if (InterleavedS16.class == input.getClass()) { PixelMath.plus((InterleavedS16) input, (int) value, (InterleavedS16) output); } else if (InterleavedS32.class == input.getClass()) { PixelMath.plus((InterleavedS32) input, (int) value, (InterleavedS32) output);
PixelMath.plus((GrayU8) input, (int) value, (int) lower, (int) upper, (GrayU8) output); } else if (GrayS8.class == input.getClass()) { PixelMath.plus((GrayS8) input, (int) value, (int) lower, (int) upper, (GrayS8) output); } else if (GrayU16.class == input.getClass()) { PixelMath.plus((GrayU16) input, (int) value, (int) lower, (int) upper, (GrayU16) output); } else if (GrayS16.class == input.getClass()) { PixelMath.plus((GrayS16) input, (int) value, (int) lower, (int) upper, (GrayS16) output); } else if (GrayS32.class == input.getClass()) { PixelMath.plus((GrayS32) input, (int) value, (int) lower, (int) upper, (GrayS32) output); } else if (GrayS64.class == input.getClass()) { PixelMath.plus((GrayS64) input, (long) value, (long) lower, (long) upper, (GrayS64) output); } else if (GrayF32.class == input.getClass()) { PixelMath.plus((GrayF32) input, (float) value, (float) lower, (float) upper, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.plus((GrayF64) input, value, lower, upper, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); PixelMath.plus((InterleavedU8) input, (int) value, (int) lower, (int) upper, (InterleavedU8) output); } else if (InterleavedS8.class == input.getClass()) { PixelMath.plus((InterleavedS8) input, (int) value, (int) lower, (int) upper, (InterleavedS8) output); } else if (InterleavedU16.class == input.getClass()) { PixelMath.plus((InterleavedU16) input, (int) value, (int) lower, (int) upper, (InterleavedU16) output); } else if (InterleavedS16.class == input.getClass()) { PixelMath.plus((InterleavedS16) input, (int) value, (int) lower, (int) upper, (InterleavedS16) output); } else if (InterleavedS32.class == input.getClass()) { PixelMath.plus((InterleavedS32) input, (int) value, (int) lower, (int) upper, (InterleavedS32) output); } else if (InterleavedS64.class == input.getClass()) { PixelMath.plus((InterleavedS64) input, (long) value, (long) lower, (long) upper, (InterleavedS64) output);
/** * Copies the target into the output image and applies the cosine window to it. */ protected void get_subwindow( T image , GrayF64 output ) { // copy the target region interp.setImage(image); int index = 0; for( int y = 0; y < workRegionSize; y++ ) { float yy = regionTrack.y0 + y*stepY; for( int x = 0; x < workRegionSize; x++ ) { float xx = regionTrack.x0 + x*stepX; if( interp.isInFastBounds(xx,yy)) output.data[index++] = interp.get_fast(xx,yy); else if( BoofMiscOps.checkInside(image, xx, yy)) output.data[index++] = interp.get(xx, yy); else { // randomize to make pixels outside the image poorly correlate. It will then focus on matching // what's inside the image since it has structure output.data[index++] = rand.nextFloat()*maxPixelValue; } } } // normalize values to be from -0.5 to 0.5 PixelMath.divide(output, maxPixelValue, output); PixelMath.plus(output, -0.5f, output); // apply the cosine window to it PixelMath.multiply(output,cosine,output); }
public synchronized void update( final CirculantTracker tracker ) { if( hasSelected ) { RectangleLength2D_F32 r = tracker.getTargetLocation(); selected.x0 = (int)r.x0; selected.y0 = (int)r.y0; selected.x1 = selected.x0 + (int)r.width; selected.y1 = selected.y0 + (int)r.height; GrayF64 template = tracker.getTargetTemplate(); GrayF64 response = tracker.getResponse(); if( this.template == null ) { this.template = new BufferedImage(template.width,template.height,BufferedImage.TYPE_INT_RGB); this.response = new BufferedImage(template.width,template.height,BufferedImage.TYPE_INT_RGB); tmp.reshape(template.width,template.height); } ConvertImage.convert(template,tmp); PixelMath.plus(tmp, 0.5f, tmp); PixelMath.multiply(tmp,255,0,255,tmp); ConvertBufferedImage.convertTo(tmp,this.template,true); ConvertImage.convert(response,tmp); VisualizeImageData.colorizeSign(tmp,this.response,-1); } repaint(); }