Détecter un forme rectangle dans un image en java

wahid2006 Messages postés 2 Date d'inscription mardi 21 avril 2009 Statut Membre Dernière intervention 5 avril 2010 - 5 avril 2010 à 10:22
sa9rtounsi Messages postés 15 Date d'inscription mardi 8 décembre 2009 Statut Membre Dernière intervention 29 mars 2013 - 16 avril 2010 à 16:19
SVP Comment détecter un forme rectangle dans un image en java

JE besoin de code en java pour faire terminer le PFE.
TRÈS important svp
MERCI

1 réponse

sa9rtounsi Messages postés 15 Date d'inscription mardi 8 décembre 2009 Statut Membre Dernière intervention 29 mars 2013
16 avril 2010 à 16:19
essaye avec ce code,
cet un détection de visage,
il peut vous donne un bon ide,
et bon chance...package visualisationfiltre;
import utilitairesimage.*;
import utilitairesimage.*;
import utilitairesimage.FiltresArtistiques.*;
import utilitairesimage.FiltresConvolution.*;
import utilitairesimage.FiltresCouleurs.*;
import utilitairesimage.FiltresDeformations.*;
import utilitairesimage.FiltresGeometriques.*;
import javax.swing.UIManager;

//////////////////////////////
import javax.swing.*;
import java.awt.*;
import java.awt.RenderingHints;
import javax.media.jai.operator.BandCombineDescriptor;
import java.awt.event.*;
import java.util.Vector;
import javax.media.jai.*;
import javax.media.jai.RenderedOp;
import javax.media.jai.operator.ConvolveDescriptor;
import com.sun.media.jai.codec.FileSeekableStream;
import javax.swing.ImageIcon;
import javax.media.jai.ParameterBlockJAI;
import java.awt.image.renderable.ParameterBlock;
import java.awt.Insets;
import com.sun.media.jai.widget.DisplayJAI;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.RescaleOp;
////////////////
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;

public class Cropping extends JPanel implements ActionListener
{ BufferedImage image;BufferedImage clipp7;
JMenuItem openItem;BufferedImage im;
JMenuItem saveItem;Image loadedImage ;Cropping test ;
JMenuItem exitItem;
JMenuItem eclItem,nbItem,grisItem ,saItem,dettem ;
Dimension size;JPanel pa;
Rectangle clip,cli7,mmm,ml; JMenuBar menuBar;
boolean showClip;BufferedImageOp op;
JTextField t; int intensite,saturation;
JTextField t1;static JPanel p;
JLabel la;static JLabel label;
JLabel ha;JLabel l;
int a;private static BorderLayout borderLayout1 = new BorderLayout();
int b;String ch;String ch1;
BufferedImage clipped;BufferedImage filteredImage;
public Cropping(BufferedImage image)
{

this.image = image;
size = new Dimension(image.getWidth(), image.getHeight());
showClip = false;
}

protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int x = (getWidth() - size.width)/2;
int y = (getHeight() - size.height)/2;
g2.drawImage(image, x, y, this);


if(cli7 == null)
createClip();

g2.setPaint(Color.white);
g2.draw(cli7);
if(showClip)
{
if(clip == null)
createClip();

g2.setPaint(Color.pink);
g2.draw(clip);


if(mmm== null)
createClip();

g2.setPaint(Color.blue);
g2.draw(mmm);

if(ml== null)
createClip();

g2.setPaint(Color.blue);
g2.draw(ml);
}



}

public void setClip(int x, int y)
{
// keep clip within raster
int x0 = (getWidth() - size.width)/2;
int y0 = (getHeight() - size.height)/2;
if(x < x0 || x + clip.width > x0 + size.width ||
y < y0 || y + clip.height > y0 + size.height)
return;

clip.setLocation(x, y);
repaint();

}


public void setCli7(int x, int y)
{
// keep clip within raster
int x0 = (getWidth() - size.width)/2;
int y0 = (getHeight() - size.height)/2;
if(x < x0 || x + clip.width > x0 + size.width ||
y < y0 || y + clip.height > y0 + size.height)
return;

cli7.setLocation(x, y);
repaint();

}

public void setmmm(int x, int y)
{
// keep clip within raster
int x0 = (getWidth() - size.width)/2;
int y0 = (getHeight() - size.height)/2;
if(x < x0 || x + clip.width > x0 + size.width ||
y < y0 || y + clip.height > y0 + size.height)
return;

mmm.setLocation(x, y);
repaint();

}

public void setml(int x, int y)
{
// keep clip within raster
int x0 = (getWidth() - size.width)/2;
int y0 = (getHeight() - size.height)/2;
if(x < x0 || x + ml.width > x0 + size.width ||
y < y0 || y + ml.height > y0 + size.height)
return;

ml.setLocation(x, y);
repaint();

}





public Dimension getPreferredSize()
{
return size;
}

private void createClip()
{int a=130;int b=115;

/* String ch= t.getText();
int a=Integer.parseInt(ch);
String ch1= t1.getText();
int b=Integer.parseInt(ch1);
*/
clip = new Rectangle( a ,b);
clip.x = 173;
clip.y =123;

cli7 = new Rectangle(260 ,220);
cli7.x =0;
cli7.y =100;

mmm = new Rectangle(3,3);
mmm.x =0;
mmm.y =0;

ml= new Rectangle(3,3);
ml.x =0;
ml.y =20;


}

private void clipImage()
{
BufferedImage clipped = null;
BufferedImage clipp7= null;
try
{
int w = clip.width;
int h = clip.height;
int x0 = (getWidth() - size.width)/2;
int y0 = (getHeight() - size.height)/2;
int x = clip.x ;
int y = clip.y ;
clipped = image.getSubimage(x, y, w, h);
///////////////////
int w7 = cli7.width;
int h7 = cli7.height;
int x07 = (getWidth() - size.width)/2;
int y07 = (getHeight() - size.height)/2;
int x7 = cli7.x - x0;
int y7 = cli7.y - y0;
clipp7 = image.getSubimage(x7, y7, w7, h7);

/////////////////
int w1 = mmm.width;
int h1= mmm.height;
int x00 = (getWidth() - size.width)/2;
int y00 = (getHeight() - size.height)/2;
int x1 = mmm.x - x00;
int y1 = mmm.y - y00;
//////////////////////////////
int w11 = ml.width;
int h11= ml.height;
int x000 = (getWidth() - size.width)/2;
int y000 = (getHeight() - size.height)/2;
int x11 = ml.x;
int y11 = ml.y ;

/////////////


if(clip.x>8;
int b = (rgb & 0xff);
r = r+intensite+100;
g = g+intensite+100;
b = b+intensite+100;
if (r 255) r 255;
if (g 255) g 255;
if (b 255) b 255;
int newRGB = (0xff
0
Rejoignez-nous