• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GrayU8类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中boofcv.struct.image.GrayU8的典型用法代码示例。如果您正苦于以下问题:Java GrayU8类的具体用法?Java GrayU8怎么用?Java GrayU8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GrayU8类属于boofcv.struct.image包,在下文中一共展示了GrayU8类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: drawDerivates

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static BufferedImage drawDerivates(GrayU8 input) {
    int blurRadius = 3;

    GrayU8 blurred = new GrayU8(input.width,input.height);
    GrayS16 derivX = new GrayS16(input.width,input.height);
    GrayS16 derivY = new GrayS16(input.width,input.height);

    // Gaussian blur: Convolve a Gaussian kernel
    BlurImageOps.gaussian(input,blurred,-1,blurRadius,null);

    // Calculate image's derivative
    GradientSobel.process(blurred, derivX, derivY, FactoryImageBorderAlgs.extend(input));

    // display the results
    BufferedImage outputImage = VisualizeImageData.colorizeGradient(derivX, derivY, -1);
    return outputImage;
}
 
开发者ID:ftomassetti,项目名称:SketchModel,代码行数:18,代码来源:Filtering.java


示例2: processSegment

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
/**
 *
 * @param shot
 */
@Override
public void processSegment(SegmentContainer shot) {
    long start = System.currentTimeMillis();
    LOGGER.traceEntry();

    BufferedImage image = shot.getMostRepresentativeFrame().getImage().getBufferedImage();
    if (image != null) {
        DescribeImageDense<GrayU8, TupleDesc_F64> hog = HOGHelper.getHOGDescriptors(image);
        if (hog != null && hog.getDescriptions().size() > 0) {
            float[] histogram_f = this.histogram(true, hog.getDescriptions());
            this.persist(shot.getId(), new FloatVectorImpl(histogram_f));
        } else {
            LOGGER.warn("No HOG feature could be extracted for segment {}. This is not necessarily an error!", shot.getId());
        }
    }

    LOGGER.debug("HOG.processShot() (codebook: {}) done in {}ms", this.codebook(), System.currentTimeMillis() - start);
    LOGGER.traceExit();
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:24,代码来源:HOG.java


示例3: getContours

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
/**
 * Applies a contour-detection algorithm on the provided image and returns a list of detected contours. First, the image
 * is converted to a BinaryImage using a threshold algorithm (Otsu). Afterwards, blobs in the image are detected using
 * an 8-connect rule.
 *
 * @param image BufferedImage in which contours should be detected.
 * @return List of contours.
 */
public static List<Contour> getContours(BufferedImage image) {
    /* Draw a black frame around to image so as to make sure that all detected contours are internal contours. */
    BufferedImage resized = new BufferedImage(image.getWidth() + 4, image.getHeight() + 4, image.getType());
    Graphics g = resized.getGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(0,0,resized.getWidth(),resized.getHeight());
    g.drawImage(image, 2,2, image.getWidth(), image.getHeight(), null);

    /* Convert to BufferedImage to Gray-scale image and prepare Binary image. */
    GrayF32 input = ConvertBufferedImage.convertFromSingle(resized, null, GrayF32.class);
    GrayU8 binary = new GrayU8(input.width,input.height);
    GrayS32 label = new GrayS32(input.width,input.height);

    /* Select a global threshold using Otsu's method and apply that threshold. */
    double threshold = GThresholdImageOps.computeOtsu(input, 0, 255);
    ThresholdImageOps.threshold(input, binary,(float)threshold,true);

    /* Remove small blobs through erosion and dilation;  The null in the input indicates that it should internally
     * declare the work image it needs this is less efficient, but easier to code. */
    GrayU8 filtered = BinaryImageOps.erode8(binary, 1, null);
    filtered = BinaryImageOps.dilate8(filtered, 1, null);

    /* Detect blobs inside the image using an 8-connect rule. */
    return BinaryImageOps.contour(filtered, ConnectRule.EIGHT, label);
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:34,代码来源:ContourHelper.java


示例4: getFgBoundingBox

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static ArrayList<ImageRectangle> getFgBoundingBox(List<VideoFrame> videoFrames,
		List<Pair<Integer, LinkedList<Point2D_F32>>> foregroundPaths,
		List<Pair<Integer, LinkedList<Point2D_F32>>> backgroundPaths){
	
	if (videoFrames == null || videoFrames.isEmpty() || foregroundPaths == null) {
		return null;
	}
	
	ArrayList<ImageRectangle> rects = new ArrayList<ImageRectangle>();
	ArrayList<GrayU8> masks = getFgMasksByNN(videoFrames, foregroundPaths, backgroundPaths);
	
	for(GrayU8 mask : masks){
		ImageRectangle rect = getLargestBoundingBox(mask);
		rects.add(rect);			
	}
	
	return rects;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:19,代码来源:MaskGenerator.java


示例5: getFgMasksByFilter

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static ArrayList<GrayU8> getFgMasksByFilter(List<VideoFrame> videoFrames,
		List<Pair<Integer, LinkedList<Point2D_F32>>> foregroundPaths,
		List<Pair<Integer, LinkedList<Point2D_F32>>> backgroundPaths) {

	if (videoFrames == null || videoFrames.isEmpty() || foregroundPaths == null) {
		return null;
	}
	
	ArrayList<GrayU8> masksScaled = generateScaledMasksFromPath(videoFrames, foregroundPaths);

	ArrayList<GrayU8> masksScaledSmoothed1 = createNewMasks(masksScaled);
	smoothMasks(masksScaled, masksScaledSmoothed1, 4, 2, 64, 26);
	
	ArrayList<GrayU8> masks = scaleUpMasks(masksScaledSmoothed1, videoFrames.get(0).getImage().getBufferedImage().getWidth(), videoFrames.get(0).getImage().getBufferedImage().getHeight());
	
	ArrayList<GrayU8> masksSmoothed1 = createNewMasks(masks);
	smoothMasks(masks, masksSmoothed1, 5, 2, 64, 10);
	ArrayList<GrayU8> masksSmoothed2 = createNewMasks(masks);
	smoothMasks(masksSmoothed1, masksSmoothed2, 5, 2, 64, 10);
	
	//multiply3D(masksSmoothed2,masksSmoothed2,255);
	
	return masksSmoothed2;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:25,代码来源:MaskGenerator.java


示例6: getFgMasksByNN

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static ArrayList<GrayU8> getFgMasksByNN(List<VideoFrame> videoFrames,
		List<Pair<Integer, LinkedList<Point2D_F32>>> foregroundPaths,
		List<Pair<Integer, LinkedList<Point2D_F32>>> backgroundPaths) {

	if (videoFrames == null || videoFrames.isEmpty() || foregroundPaths == null) {
		return null;
	}

	ArrayList<GrayU8> masks = generateMasksFromPath(videoFrames, foregroundPaths, backgroundPaths);
			
	ArrayList<GrayU8> masksSmoothed1 = createNewMasks(masks);
	smoothMasks(masks, masksSmoothed1, 21, 2, 64, 26);
	ArrayList<GrayU8> masksSmoothed2 = createNewMasks(masks);
	smoothMasks(masksSmoothed1, masksSmoothed2, 11, 2, 64, 26);
	
	//multiply3D(masksSmoothed2,masksSmoothed2,255);
	
	return masksSmoothed2;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:20,代码来源:MaskGenerator.java


示例7: smoothMasks

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static ArrayList<GrayU8> smoothMasks(ArrayList<GrayU8> input, ArrayList<GrayU8> output,
		int spatialRadius, int temporalRadius, double multipyFactor, int threshold){
	
	if(input == null || input.isEmpty()){
		return input;
	}
	if(output == null){
		output = createNewMasks(input);
	}
	if(output.size() != input.size()){
		throw new IllegalArgumentException("size of input and output do not match. input: "+input.size()+" output: "+output.size());
	}
	
	multiply3D(input, input, multipyFactor);
	gaussianFilter3D(input, output, spatialRadius, temporalRadius);
	threshold3D(output,output,threshold);
	
	return output;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:20,代码来源:MaskGenerator.java


示例8: gaussianFilterTemporal

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static ArrayList<GrayU8> gaussianFilterTemporal(ArrayList<GrayU8> input, ArrayList<GrayU8> output, int spatialRadius){
	int width = input.get(0).getWidth();
	int height = input.get(0).getHeight();
	int len = input.size();
	
	Kernel1D_I32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_I32.class,-1,spatialRadius);
	int divisor = kernel.computeSum();
	int data1D[] = new int[len + 2*kernel.offset];
	for (int x = 0; x < width; ++x){
		for (int y = 0; y < height; ++y){
			for(int i = 0; i < len; ++i){
				data1D[i + kernel.offset] = input.get(i).get(x, y);
			}
			for(int i = 0; i < len; ++i){
				int total = 0;
				for (int k = 0; k < kernel.width; ++k){
					total += (data1D[i+k] & 0xFF) * kernel.data[k];
				}
				output.get(i).set(x, y, total/divisor);
			}
		} 
	}
	
	return output;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:26,代码来源:MaskGenerator.java


示例9: denseSampling

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static LinkedList<PyramidKltFeature> denseSampling( GrayU8 image, GrayS16[] derivX, GrayS16[] derivY,
														int samplingInterval,
														PkltConfig configKlt,
														ImageGradient<GrayU8, GrayS16> gradient,
														PyramidDiscrete<GrayU8> pyramid,
														PyramidKltTracker<GrayU8, GrayS16> tracker){
	LinkedList<PyramidKltFeature> tracks = new LinkedList<PyramidKltFeature>();
	
	pyramid.process(image);
	derivX = declareOutput(pyramid, derivX);
	derivY = declareOutput(pyramid, derivY);
	PyramidOps.gradient(pyramid, gradient, derivX, derivY);
	tracker.setImage(pyramid,derivX,derivY);
	
	for( int y = 0; y < image.height; y+= samplingInterval ) {
		for( int x = 0; x < image.width; x+= samplingInterval ) {
			PyramidKltFeature t = new PyramidKltFeature(configKlt.pyramidScaling.length,configKlt.templateRadius);
			t.setPosition(x,y);
			tracker.setDescription(t);
			tracks.add(t);
		}
	}
	return tracks;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:25,代码来源:PathList.java


示例10: getEdgePixels

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static boolean[] getEdgePixels(MultiImage img, boolean[] out) {
	LOGGER.traceEntry();

	if (out == null || out.length != img.getWidth() * img.getHeight()) {
		out = new boolean[img.getWidth() * img.getHeight()];
	}

	GrayU8 gray = ConvertBufferedImage.convertFrom(img.getBufferedImage(), (GrayU8) null);

	if(!isSolid(gray)){
		getCanny().process(gray, THRESHOLD_LOW, THRESHOLD_HIGH, gray);
		
	}

	for (int i = 0; i < gray.data.length; ++i) {
		out[i] = (gray.data[i] != 0);
	}

	LOGGER.traceExit();
	return out;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:22,代码来源:EdgeImg.java


示例11: countPills

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
/**
 * Count pills.
 *
 * @param image the image
 * @return the int
 * @throws Exception the exception
 */
public static int countPills( BufferedImage image ) throws Exception {
	GrayF32 input = ConvertBufferedImage.convertFromSingle(image, null, GrayF32.class);
	GrayU8 binary = new GrayU8(input.width,input.height);
	int totPixels = 0;
	for( int x = 0 ; x<input.width ; x++ ) {
		for( int y=0 ; y<input.height ; y++ ) {
			int binout = input.get(x, y) < PIXEL_THRESHOLD ? 0 : 1;
			binary.set(x, y, binout );
			totPixels += binout;
		}
	}
	dumpImage(binary, input.width, input.height );
	
	int numPills = -1;
	for( int checkNumPills=1 ; checkNumPills<CHECK_MAX_NUM_PILLS ; checkNumPills++ ) {
		int checkMaxPixels = (int)(checkNumPills * PIXELS_PER_PILL * PIXELS_PER_PILL_FUDGE_FACTOR);
		if( totPixels <= checkMaxPixels ) {
			numPills = checkNumPills;
			break;
		}
	}
	logger.info("NumPills found in image: {}", numPills);
	return numPills;
}
 
开发者ID:petezybrick,项目名称:iote2e,代码行数:32,代码来源:PillDispenser.java


示例12: convert_RGB_U8

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static void convert_RGB_U8( PImage input , GrayU8 output ) {

		int indexInput = 0;
		for( int y = 0; y < input.height; y++ ) {
			int indexOut = output.startIndex + y*output.stride;
			for( int x = 0; x < input.width; x++ ,indexInput++,indexOut++) {
				int value = input.pixels[indexInput];

				int r = ( value >> 16 ) & 0xFF;
				int g = ( value >> 8 ) & 0xFF;
				int b = value & 0xFF;

				output.data[indexOut] = (byte)((r+g+b)/3);
			}
		}
	}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:17,代码来源:ConvertProcessing.java


示例13: convert_PU8_RGB

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static void convert_PU8_RGB(Planar<GrayU8> input , PImage output ) {

		GrayU8 red = input.getBand(0);
		GrayU8 green = input.getBand(1);
		GrayU8 blue = input.getBand(2);

		int indexOutput = 0;
		for( int y = 0; y < input.height; y++ ) {
			int indexInput = input.startIndex + y*input.stride;
			for( int x = 0; x < input.width; x++ ,indexOutput++,indexInput++) {
				int r = (red.data[indexInput]&0xFF);
				int g = (green.data[indexInput]&0xFF);
				int b = (blue.data[indexInput]&0xFF);

				output.pixels[indexOutput] = 0xFF << 24 | r << 16 | g << 8 | b;
			}
		}
	}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:19,代码来源:ConvertProcessing.java


示例14: convert_RGB_PU8

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static void convert_RGB_PU8(PImage input , Planar<GrayU8> output ) {

		GrayU8 red = output.getBand(0);
		GrayU8 green = output.getBand(1);
		GrayU8 blue = output.getBand(2);

		int indexInput = 0;
		for( int y = 0; y < input.height; y++ ) {
			int indexOutput = output.startIndex + y*output.stride;
			for( int x = 0; x < input.width; x++ ,indexOutput++,indexInput++) {
				int value = input.pixels[indexInput];

				red.data[indexOutput] = (byte)(value>>16);
				green.data[indexOutput] = (byte)(value>>8);
				blue.data[indexOutput] = (byte)value;
			}
		}
	}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:19,代码来源:ConvertProcessing.java


示例15: histogramEqualize

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
/**
 * Equalizes the histogram across the entire image
 *
 * @see EnhanceImageOps
 * @return New SimpleGray after equalize histogram has been applied
 */
public SimpleGray histogramEqualize() {
	if (!(image instanceof GrayU8))
		throw new RuntimeException("Image must be of type GrayU8 to adjust its histogram");

	GrayU8 adjusted = new GrayU8(image.width, image.height);

	int histogram[] = new int[256];
	int transform[] = new int[256];

	ImageStatistics.histogram((GrayU8) image, histogram);
	EnhanceImageOps.equalize(histogram, transform);
	EnhanceImageOps.applyTransform((GrayU8) image, transform, adjusted);

	return new SimpleGray(adjusted);
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:22,代码来源:SimpleGray.java


示例16: main

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static void main(String[] args) {
  try {

    LoggingFactory.init(Level.INFO);

    // ImageType<Planar<GrayU8>> colorType = ImageType.pl(3,GrayU8.class);
    BoofCv boofcv = (BoofCv)Runtime.start("boofcv", "BoofCv");
    ObjectTracker<GrayU8> tracker = boofcv.createTracker();
    tracker.start();
    Service.sleep(5000);
    tracker.stop();
    
    // BoofCV template = (BoofCV) Runtime.start("template", "BoofCV");
    // Runtime.start("gui", "SwingGui");
  } catch (Exception e) {
    Logging.logError(e);
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:19,代码来源:BoofCv.java


示例17: main

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static void main(String[] args) {

    // ImageType<Planar<GrayU8>> colorType = ImageType.pl(3,GrayU8.class);

    TrackerObjectQuad<GrayU8> tracker =
    // FactoryTrackerObjectQuad.circulant(null, GrayU8.class);
    // FactoryTrackerObjectQuad.sparseFlow(null,GrayU8.class,null);
    FactoryTrackerObjectQuad.tld(null, GrayU8.class);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new
    // ConfigComaniciu2003(), colorType);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new
    // ConfigComaniciu2003(true),colorType);
    // FactoryTrackerObjectQuad.meanShiftLikelihood(30,5,255,
    // MeanShiftLikelihoodType.HISTOGRAM,colorType);

    ObjectTracker<GrayU8> app = new ObjectTracker<GrayU8>(tracker, 640, 480);

    app.start();
  }
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:20,代码来源:ObjectTracker.java


示例18: getCannyContours

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static List<Contour> getCannyContours(BufferedImage image) {
	GrayU8 gray = ConvertBufferedImage.convertFrom(image, (GrayU8) null);
	GrayU8 edgeImage = gray.createSameShape();
	canny.process(gray, 0.1f, 0.3f, edgeImage);
	List<Contour> contours = BinaryImageOps.contour(edgeImage, ConnectRule.EIGHT, null);

	return contours;
}
 
开发者ID:ForOhForError,项目名称:MTG-Card-Recognizer,代码行数:9,代码来源:FindCardCandidates.java


示例19: maskBackground

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public static BufferedImage maskBackground(BufferedImage image) {
    GrayU8 gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class);
    int threshold = gray.get(1, 1); // get background pixel - would be better to average some
    GrayU8 binary = ThresholdImageOps.threshold(gray, null, threshold, true);
    GrayF32 mask = ConvertImage.convert(binary, (GrayF32) null);
    return mask(image, mask);
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:8,代码来源:ImageUtils.java


示例20: equalize

import boofcv.struct.image.GrayU8; //导入依赖的package包/类
public GrayImageProcessor equalize() {
    int histogram[] = new int[256];
    int transform[] = new int[256];
    ImageStatistics.histogram(image, histogram);
    EnhanceImageOps.equalize(histogram, transform);
    GrayU8 newImage = image.createSameShape();
    EnhanceImageOps.applyTransform(image, transform, newImage);
    addImageToPanel(newImage, String.format("Equalize"));
    return new GrayImageProcessor(newImage);
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:11,代码来源:ImageProcessingPipeline.java



注:本文中的boofcv.struct.image.GrayU8类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java State类代码示例发布时间:2022-05-22
下一篇:
Java Issue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap