Implement a Program for Feature Extraction in 2D Colour Images (
features like Colour, Texture etc.)
Aim : To implement Program for Feature Extraction in 2D Colour Images .
Objective : To study Program for Feature Extraction in 2D Colour Images for features like ..Colour and Textures .
Given Feature Extraction source code is implemented using Java language . The input to the program is image file that is to be modified using program by changing colour .
Feature Extraction source code :
package com.prac.prac; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.util.*; import javax.imageio.ImageIO; public class Exatraction { private static BufferedImage orignal,answer; public static void main(String[] args) throws IOException{ File orignal_f=new File("a.jpg"); orignal = ImageIO.read(orignal_f); answer=imageHistogram(orignal); writeImage("featureExtraction"); } private static void writeImage(String output) throws IOException { File file = new File(output+".jpg"); ImageIO.write(answer, "jpg", file); } private static int colorToRGB(int alpha, int red, int green, int blue) { int newPixel = 0; newPixel += alpha; newPixel = newPixel << 8; newPixel += red; newPixel = newPixel << 8; newPixel += green; newPixel = newPixel << 8; newPixel += blue; return newPixel; } public static BufferedImage imageHistogram(BufferedImage input) { BufferedImage redGraph = new BufferedImage(input.getWidth(),input.getHeight(),input.getType()); for(int i=0; i<input.getWidth(); i++) { for(int j=0; j<input.getHeight(); j++) { int alpha =new Color(input.getRGB (i, j)).getAlpha(); int red = new Color(input.getRGB (i, j)).getRed(); int green = new Color(input.getRGB (i, j)).getGreen(); int blue = new Color(input.getRGB (i, j)).getBlue(); redGraph.setRGB(i, j, colorToRGB(alpha, 0,0,blue)); } } return redGraph; } }
Input to the Program :
Output from the Program :
Leave a Reply