Skip to content

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

Notifications You must be signed in to change notification settings

RylanSanders/ImageOp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published