Git Product home page Git Product logo

imageop's Introduction

ImageOp

This is a library that I wrote for performing Image Operations. I intended it to be easily integrated with the core java functional interfaces/ streams library.

Please note that I did not write the Perlin Noise, GifSequenceWriter, or the Delauney Triangle code. The real authors are listed in the code.

For examples on how to use it look that the Data2Test class.

Some example of things that it can do:

Canny Edge Detection with Gif Generation

alt text

Code:

 
BufferedImage cat = SourceOperations.fileSource(exampleImgs + "cat_simple_background.jpg").FileToImg().img();
SourceOperations.generateIntListOp(0, 600, x->x+10) //Generate the different parameters to use
	.monitor(x->System.out.println(x)) //Status update - print out the parameter that is being used
	.map(num->
			SourceOperations.imgSource(cat)
			.maskComposite(
					SourceOperations.imgSource(cat)
					.detectEdges(1, 600-num)
					.img()
					) //Maps the parameter to the actual image
			.img()
			)
	.consume(x->GifUtil.generateGif(x, "example.gif", 25));  //Generates the gif off over the list of images

Pixelization with a control panel for testing different input parameters:

alt text

alt text

Code:

 
Consumer<List<Object>> r = (arr)->SourceOperations.fileSource(exampleImgs + "BookV1.jpg")
	.FileToImg()  
    	.simpleSharpen() 
    	.tolerancePixelize((int)arr.get(0), (int)arr.get(1)) 
    	.showImage();
//This Control Panel sets up a panel to use for input values to the consumer. The strings are a very basic configuration for the panel controls 
new ControlPanel(r, "Slider Tolerance 1 255", "Slider Pix 1 1100");
	

Delauney Triangulation for an image with edge detection and kernel operations for specifying points

alt text

Code:

 SourceOperations.fileSource(exampleImgs + "cat_simple_background.jpg")
	.FileToImg()
	.detectEdges(65, 150) //Use Canny Edge Detection
	.aside(x->x.showImage()) //Show the edges image but continue the operation
	.kernelPixelOperation(4, 4, group->{
		int hits = group.pixels.stream().mapToInt(p->{
			if(p.getColor().equals(Color.black))
				return 0;
			return 1;
		})
		.sum();
		group.pixels.stream().forEach(p->p.setColor(Color.black));
		if(hits>6) {
			 group.getPixels().get(8).setColor(Color.white);
		}
		return group;
	}) //Split the Image into 4x4 kernels and if a kernal contains more than 6 white pixels then mark it as white and make all other black
	.toPixelList()
	.aside(lst->lst.buildOperation(OperationBuilders.PixelListToImage()).showImage()) // Show the image with the condensed points for the edges
	.filter(p->p.color==Color.WHITE.getRGB())
	.map((Function<Pixel,imageOp.Point>)(p->new imageOp.Point(p.x, p.y))) //Convert the white pixels to geometric points
	.buildOperation(points -> new ListOperation(Geometry.delanyTriangulationV2(points))) //Use Delauney triangulation to convert the points to triangles
	.map(t->(IDrawable)t)
	.buildOperation(OperationBuilders.GeometryToImage(474, 842)) //Build the shapes into an image
	.showImage();

imageop's People

Contributors

rylansanders avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.