0

I have a project to carry out, my company does the design of advertising panels (design and printing). when calculating pricing (area * material price) we find several difficulties because of inaccurate area that we calculate manually because of the irregular shape of the design (it contains several curvature). So we thought of making an application that can calculate the price and the exact area of a shape. I have several ideas but I walk slowly starting with the java language .... I uploaded an image from my desktop, this image has an irregular shape with bends. i draw it by adobe illustrator and convert it to jpeg .. my question is: how do i calculate the area of this shape. I started to load it with java and draw it with this code

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ImagePanel extends JPanel {
     /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public BufferedImage image;   
    public ImagePanel()
    {
         try {                
              image = ImageIO.read(new File("C:/Users/pc/Desktop/Inés/image.jpg"));
           } catch (IOException ex) {
                // handle exception...
               System.out.println(ex.getMessage());
           }
    }
     @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(image, 0, 0, this); // see javadoc for more info on the parameters            
        }
    
}

and then do some calculations but I'm stuck. If you have any solution please help me. If I use other language or software already exist thank you.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Something like [this](https://stackoverflow.com/questions/19873596/convex-hull-area-in-python) would likely work for you. Convex hull is pretty easy to implement in Python with scipy. – brobertsp Apr 19 '21 at 12:45
  • thank you for your answer sir, I will study it well. but I would like to measure the surface of the shapes and not redraw them . – INES SEHILI Apr 19 '21 at 13:20
  • That is precisely what a convex hull does, given a group of points it defines the polygon that encapsulates all of those points and then you just calculate the area of that polygon (in the case of scipy its the volume). – brobertsp Apr 19 '21 at 15:31
  • Ok, thank you sir very much. – INES SEHILI Apr 20 '21 at 08:43

0 Answers0