Sakai
Compute the image processing
0 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners
Hi,

Question 1:

I have some questions here first I need some suggestion - I cannot find what went wrong with my code here to find the averaging of the image (grey image) also, How do i compute an average with a colour images one?

Question 2:
I need to compute the subtraction of the image using hte g(x,y) = |f1(x,y) - f2(x,y) How do i change the code so it will implement the subtraction by inputing two images in the Subtraction program?

Question 3:
I need to find the Brightness by adding the constant to all value which is
g'(x,y) = g(x,y) + k. Say k = 50.

Question 4:
Finding the contrast of the image by scale all value by constant of
g'(x,y) = g(x,y) * k. Say k = 1.5


Thanks
==========================================================================

import java.io.*;
import java.awt.image.*;
import java.awt.color.ColorSpace;
import javax.swing.*;
import com.pearsoneduc.ip.io.*;
import com.pearsoneduc.ip.gui.*;

public class AverageXImage extends JFrame {

private BufferedImage sourceImage;
private ImageView[] views;


public AverageXImage(String imageFile) throws IOException, ImageDecoderException {

super("xAverage: " + imageFile);
readImage(imageFile);

views = new ImageView[2];
views[0] = new ImageView(sourceImage);

Error found in this line---- views[1]=newImageView(average(sourceImage);

JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add(new JScrollPane(views[0]), "input");
tabbedPane.add(new JScrollPane(views[1]), "xAverage");

getContentPane().add(tabbedPane);
addWindowListener(new WindowMonitor());
}
public void readImage(String filename)
throws IOException, ImageDecoderException {
ImageDecoder input = ImageFile.createImageDecoder(filename);
sourceImage = input.decodeAsBufferedImage();
if (sourceImage.getType() != BufferedImage.TYPE_BYTE_GRAY) {

System.err.println("Converting colour image to greyscale image...");
ColorConvertOp op = new ColorConvertOp(
ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
BufferedImage greyImage = op.filter(sourceImage, null);
sourceImage = greyImage;
}
}

public BufferedImage average(BufferedImage[] imgArray) {
//instantiate a new image object

int n = imgArray.length;
int w = n*imgArray[0].getWidth();
int h = n*imgArray[0].getHeight();

BufferedImage AvgImage = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);

for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x){
//here is to save the original image
float sum = 0.0f;
for (int i = 0; i < n; ++i)
sum += imgArray[i].getRaster().getSample(x, y, 0);
AvgImage.getRaster().setSample(x, y, 0, Math.round(sum/n));
}
return AvgImage;
}
public static void main(String[] argv) {
if (argv.length > 0) {

try {
JFrame frame = new AverageXImage(argv[0]);

frame.pack();
frame.setVisible(true);
} catch (Exception e) {
System.err.println(e);
System.exit(0);
}
} else {
System.err.println("usage: java enlarge <imagefile> ");
System.exit(1);
}
}
}


Advertisement
View Answers









Related Tutorials/Questions & Answers:
Compute the image processing - Java Beginners
Compute the image processing  Hi, Question 1: I have some... code here to find the averaging of the image (grey image) also, How do i compute an average with a colour images one? Question 2: I need to compute
image Processing
image Processing   BCIF Image Compresssion Algorithm s alossless image Compression algorithm ,Pleas Help Me weather it can support only 24 bit bmp images
Advertisements
Image processing
Image processing  i want a browsing program in java in which we hv a small img and we hv to browse this img on a big image so that we can find the similar type of image in big img
image Processing
image Processing  Please give Me a JPEG or GIf "LOSS LESS" Image Compression and Decompression Source Code Please Help Me I don't want links Kindly help me Compression ratio not matter
image processing matching an 2 image
image processing matching an 2 image  source code for dense and sparse matching feature in lbp
image processing - Java3D
image processing  hii i have to compare 2 images. for this i try to convert image into greyscale. i think the greyscale comparisonn is more effective than that of colour. pls give me the processing details.  Hi friend
image processing in java
image processing in java  public class testing { static BufferedImage image; public static void main(String[] args) throws IOException...;Integer>(); image = ImageIO.read(new File("nn33.png")); int w
Image Processing Java
Image Processing Java  Using This Code I Compressed A JPEG Image And the Original Size of the image is 257kb and The Compressed Image Size Is 27kb...; import com.sun.media.jai.widget.DisplayJAI; /* * Shows how to save an image
jaav image processing
jaav image processing  hello there, i am an engineering student.. i am going to do and project in whcih the software provides the user... to destination over an image.. can you please guide me on how to start
compute
compute  B. Write a JavaScript program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds eight hours add 30% to each excess
compute
compute    Write a menu driven program that will print out the results of the following : (1) Ceiling (2) Floor (3) Absolute (4) (a+b)^3 (5) Exit... at 25% Input the name and marks of 25 students and compute the average. Print out
compute
compute  B. Write a JavaScript program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage... Name, Rate per hour, No. of hours worked and will compute the daily wage
Image Processing Tutorials in Java Programming Language
Tutorials and example of processing the image in the Java Programming Language Java Programming Language is providing many APIs for processing the image... image processing routine in the Java Program. This is available with JDK
Compute command
Compute command  hello, What is compute command?   hii, samar Compute command control computations on subsets created by the BREAK command
how to make use of jerry's java image processing filter in java application?is there anyway to do this?
how to make use of jerry's java image processing filter in java application?is there anyway to do this?   how to make use of jerry's java image processing filter in java application?is there anyway to do
data processing is
data processing is   data processing is   Data processing is associated with commercial work. Data processing is also referred as Information System. Data processing is basically used for analyzing, processing
compute the average of degrees
compute the average of degrees  using c++ language , write a program to do the following 1 enter three degrees of a student by the user . 2 compute the average of his degrees
compute the daily wage of an employee.
compute the daily wage of an employee.   B. Write a JavaScript program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds
compute the daily wage of an employee.
compute the daily wage of an employee.   B. Write a JavaScript... and will compute the daily wage of an employee. If the number of hours worked exceeds... and will compute the daily wage of an employee. If the number of hours worked
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute nth root - Java Beginners
compute nth root  write a program that computes the nth root... Y, compute the nth root Z such that Z*Z*Z*Z*Z*Z*Z...(Y times)..Z*Z=X, or Z^y=X... and the program calculates Z. Compute Z so that when Z is multiplied Y time
Steps for the payment gateway processing?
Steps for the payment gateway processing?  Steps for the payment gateway processing
request processing in servlets
request processing in servlets  how request processing is done in servlets and jsp   Please visit the following links: JSP Tutorials Servlet Tutorials Here, you will find several examples of processing request
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
The product of data processing is
The product of data processing is   The product of data processing is 1. Data 2. Information 3. Software 4. Computer 5. All of the above   Answer: 3. Software
Abort JSP processing
Abort JSP processing  Can I just abort processing a JSP?   Yes. You can put a return statement to abort JSP processing
Advertisement