Total members 11756 |It is currently Sat Nov 17, 2018 9:59 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 5340 times ]
Author:
Mastermind
User avatar Posts: 2707
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 button in flash     -  
 make Curves in photoshops     -  
 make class of date     -  
 Make A Website In Flash     -  



Topic Tags

Java Image






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