Total members 11893 |It is currently Tue Nov 05, 2024 5:31 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





make Noise on Image in java
Code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.Random;
import javax.swing.*;

public class 
NoiseImage extends JComponent implements Runnable {
  
byte[] b;
  
BufferedImage bufferedImage;
  
Random ran;

  public 
void init() {
    
int wid getSize().widthht getSize().height;
    
int length = ((wid 5) * ht) / 7;
    
= new byte[length];
    
DataBuffer dataBuffer = new DataBufferByte(blength);
    
WritableRaster raster Raster.createPackedRaster(dataBufferwidht1null);
    
ColorModel colorModel = new IndexColorModel(12, new byte[] { 
      (
byte0, (byte250} ,  new byte[]  {(byte0,  (byte250 },  new byte[]  {      (byte0, (byte250 });
    
bufferedImage = new BufferedImage(colorModelrasterfalsenull);
    
ran = new Random();
    new 
Thread(this).start();
  }
    public 
void run() {
    while (
true) {
      
ran.nextBytes(b);
      
repaint();
      try {
        
Thread.sleep(80);
      } catch (
Exception e) { 
      }
    }
  }
  public 
void paint(Graphics graphics) {
    if (
bufferedImage == null)
    
init();
    
graphics.drawImage(bufferedImage00this);
  }
  public static 
void main(String[] args) {
    
JFrame frame = new JFrame();
    
frame.add(new NoiseImage());
    
frame.setSize(250250);
    
frame.setVisible(true);
  }





Attachments:
File comment: Image will be displayed as:
noiseImage.gif
noiseImage.gif [ 8.99 KiB | Viewed 7501 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : make Noise on Image
 Image-Viewer-Image Processing-Filters-Noise-enhancements     -  
 Image Noise Filter in Java     -  
 Move image in front of a background image     -  
 different between cfa image and gray level image     -  
 make a banner     -  
 PNG image to the image you generated     -  
 make Dynamic Bar Chart by php     -  
 Make An Ebook Cover     -  
 Make a call using java     -  
 How make a report using IReport on JSP?     -  



Topic Tags

Java Image
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com