A small addition (foot length measuring tool) to the Pedograph Software

Pedograph is a medical device for measuring the variation of foot pressure at the various points  under the sole.
“Diabetic patients usually suffer from lack of nerve sensation, especially in the feet. Therefore, their gait on standing and during walking may deviate from that of a normal person and points of high pressure develop under the feet. However, due to neuropathy they do not feel any pain which would have been felt had the nerve functions were alright. Later, ulcers form at these high pressure points, leading to gangrene and eventual amputation of the leg. A Pedograph revealing the variation of foot pressure at various points under the sole easily delineates such high pressure regions at an early stage so that special shoe insoles can be prepared to spread the pressure away from the hot spots. This way the patient is saved from eventual amputation, from being crippled for the entire life. Again, pressure points and pattern may differ while standing and during walking, usually it is the latter which put the soles on greater burden, and a dynamic pressure measurement during walking has more importance from a clinical point of view.” (https://bibeat.com/product/dynamic-pedograph/)

The main sensor unit (Fig) uses an optical method to create an
image of light intensities proportional to the pressure impressed at
individual points. This sensor unit provides a video image and rest of the work is done by software.
In this software, I have added a tool for measuring foot length from the composite image.

Foot length measurement tool

 

Below is the fundamental portion of the code.

private void footDisplayPanelMouseClicked(java.awt.event.MouseEvent evt) {                                              
        // TODO add your handling code here:
    int FootLength = 0;
    int footLengthinInch = 0;
    float ResultofFootlenthInInch =0;
        MAclickCount++;
        Integer x = evt.getX(), y = evt.getY();
        Graphics g = footDisplayPanel.getGraphics();
        Graphics2D g2 = (Graphics2D) g;
        g2.setStroke(new BasicStroke(3));
        
        
        int alpha = 127; // 50% transparent
        Color myColour = new Color(255, 255, 255, alpha); // transparent white
        
        g.setColor(Color.WHITE);   // this is the code for pointer// the white '+' symbol 
        g.drawLine(x, y-15, x, y+15);
        g.drawLine(x-15, y, x+15, y);
        
        footLengthinInch = Constants.DEFAULT_PIXELS_PER_INCH;
        
     if (MAclickCount>1){
//        super.paint(g);
         g.setColor(Color.red);
         
        g2.drawLine(PreviousX, PreviousY, x, y); 
        
        FootLength = (int) Math.sqrt(((PreviousX-x)*(PreviousX-x))+((PreviousY-y)*(PreviousY-y)));
        ResultofFootlenthInInch = (float)FootLength/footLengthinInch; 
        
//        footDisplayPanel.setBackground(myColour);
//        DisplayLength.setBackground(myColour);
        DisplayLength.setText("Lenght of The Foot = "+(String.format("%.2f", ResultofFootlenthInInch))+" Inch or "+FootLength+" Pixels");
//        DisplayLength.setBackground(myColour);
       
     }
     if (MAclickCount>=2){ // for refreaching after two click. 
         PreviousX = 0;
         PreviousY = 0;
         MAclickCount =0;
         x =0;
         y=0;
     }
     PreviousX = x;
     PreviousY = y;

    }
Foot length measuring tool's code

 

This will be updated to ..

public class CIDPforFootSizeMeasurement extends javax.swing.JPanel {

    /**
     * private variables
     */    
    private BufferedImage jpeg = null;
    private int W = 0;
    private int H = 0;
    /**
     * public variables, accessed from CompositeImageFrame
     */
    public Ellipse2D.Float selectedCircle = null;
    public HashMap circles = new HashMap();
    public int currentFrameIndex,  startFrameIndex,  endFrameIndex;
    public Project project;
    int MAclickCount = 0;
    int TotalClick;
    int PreviousX = 0;
    int PreviousY =0;
    String ALLTEXT;
    String TotalALLTEXT = "";
    
    
    /** Creates new form FootDrawingPanel */
    public CIDPforFootSizeMeasurement(Project project) throws IOException {
        initComponents();
        this.project = project;
        this.startFrameIndex = (project.getStartFrameIndex() < 1) ? 1 : project.getStartFrameIndex();
        this.endFrameIndex = (project.getEndFrameIndex() < 1) ? project.getNumFrames() : project.getEndFrameIndex();
        this.currentFrameIndex = startFrameIndex;

        try {
            myInit();
        } catch (IOException ex) {
            throw ex;
        }
        this.setSize(W+250, H);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

  public void paintComponent(Graphics g) {
    super.paintComponent(g);
  }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        footDisplayPanel = new javax.swing.JPanel();
        DisplayLength = new javax.swing.JLabel();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(analyzervideofoot.AnalyzerVideoFootApp.class).getContext().getResourceMap(CIDPforFootSizeMeasurement.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N

        footDisplayPanel.setToolTipText(resourceMap.getString("footDisplayPanel.toolTipText")); // NOI18N
        footDisplayPanel.setAutoscrolls(true);
        footDisplayPanel.setName("footDisplayPanel"); // NOI18N
        footDisplayPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                footDisplayPanelMouseClicked(evt);
            }
        });

        DisplayLength.setFont(resourceMap.getFont("DisplayLength.font")); // NOI18N
        DisplayLength.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        DisplayLength.setText(resourceMap.getString("DisplayLength.text")); // NOI18N
        DisplayLength.setToolTipText(resourceMap.getString("DisplayLength.toolTipText")); // NOI18N
        DisplayLength.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        DisplayLength.setName("DisplayLength"); // NOI18N

        javax.swing.GroupLayout footDisplayPanelLayout = new javax.swing.GroupLayout(footDisplayPanel);
        footDisplayPanel.setLayout(footDisplayPanelLayout);
        footDisplayPanelLayout.setHorizontalGroup(
            footDisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, footDisplayPanelLayout.createSequentialGroup()
                .addContainerGap(172, Short.MAX_VALUE)
                .addComponent(DisplayLength, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        footDisplayPanelLayout.setVerticalGroup(
            footDisplayPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(footDisplayPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(DisplayLength, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(footDisplayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(footDisplayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>

    private void footDisplayPanelMouseClicked(java.awt.event.MouseEvent evt) {                                              
        // TODO add your handling code here:
    int FootLength = 0;
        MAclickCount++;
        Integer x = evt.getX(), y = evt.getY();
        Graphics g = footDisplayPanel.getGraphics();
        Graphics2D g2 = (Graphics2D) g;
        g2.setStroke(new BasicStroke(3));
        
        g.setColor(Color.white);
        g.drawLine(x, y-15, x, y+15);
        g.drawLine(x-15, y, x+15, y);
        
     if (MAclickCount>1){
         TotalClick++;
//        super.paint(g);
         g.setColor(Color.red);
         
        g2.drawLine(PreviousX, PreviousY, x, y);
        
        g.setColor(Color.black);
        g.setFont(new Font("default", Font.BOLD, 20));
        g2.drawString(Integer.toString(TotalClick), (PreviousX+x)/2, (PreviousY+y)/2);
        
        FootLength = (int) Math.sqrt(((PreviousX-x)*(PreviousX-x))+((PreviousY-y)*(PreviousY-y)));
        
        ALLTEXT = "<p>"+TotalClick+". Lenght of The Foot = "+FootLength+"</p>";
        TotalALLTEXT = TotalALLTEXT + ALLTEXT;
        
        DisplayLength.setText("<html>"+TotalALLTEXT+"</html>");
     }
     if (MAclickCount>=2){ // for refreaching after two click. 
         PreviousX = 0;
         PreviousY = 0;
         MAclickCount =0;
         x =0;
         y=0;
     }
     PreviousX = x;
     PreviousY = y;

    }                                             

    
    private void myInit() throws IOException {
        try {
            BufferedImage temp = ImageIO.read(new File(project.getJpegDirectory().getPath() + File.separator + "max_2.jpg"));

            BufferedImage currentFrame = temp;
            W = currentFrame.getWidth();
            H = currentFrame.getHeight();

            jpeg = ImageUtility.getColoredImage(temp);

        } catch (IOException e) {
            JOptionPane.showMessageDialog(null, "Foot image max_2.jpg not found", "ERROR", JOptionPane.ERROR_MESSAGE);
            throw e;
        }
    }

 

 

added print and image resize option:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CIFforFootSizeMeasurement2.java
 *
 * Created on Jul 31, 2018, 3:34:08 PM
 */
package analyzervideofoot;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.PrintJob;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author BMPT-MARUF
 */


public class CIFforFootSizeMeasurement2 extends javax.swing.JFrame {
    String snapshotLocation ="/Printable.gif";
    String expandedImageLocation = "/DoubleSizedImage.gif";

    private CIDPforFootSizeMeasurement cidp;
//    private Point lastPoint = null;
    private GraphOutputFrame gof = null;

    /** Creates new form FootOutputFrame */
    public CIFforFootSizeMeasurement2(CIDPforFootSizeMeasurement cidp) {
        initComponents();

        this.cidp = cidp;
        footPanel.add(this.cidp);
        footPanel.setSize(this.cidp.getWidth(), this.cidp.getHeight());
        this.setSize(this.cidp.getWidth() + 16, this.cidp.getHeight() + 105);

//        diameterSlider.setValue(Constants.DEFAULT_CIRCLE_DIAMETER);
    }
    
    void takeSnapShot(JPanel panel ){
       BufferedImage largedImage;
       BufferedImage image4expand;
       BufferedImage bufImage = new BufferedImage(panel.getSize().width, panel.getSize().height,BufferedImage.TYPE_INT_RGB);
  //     largedImage = enlarge(bufImage,2); 
      panel.paint(bufImage.createGraphics());
 //      panel.paint(largedImage.createGraphics());
       File imageFile = new File("."+File.separator+snapshotLocation);
    try{
        imageFile.createNewFile();
        ImageIO.write(bufImage, "gif", imageFile);
 //       ImageIO.write(largedImage, "gif", imageFile);
        image4expand = ImageIO.read(new File("Printable.gif"));
        largedImage = enlarge(image4expand,2);
        File imageFile2 = new File("."+File.separator+expandedImageLocation);
        
        try{
            imageFile2.createNewFile();
            ImageIO.write(largedImage, "gif", imageFile2);
            try{
                BufferedImage originalImage = ImageIO.read(new File("DoubleSizedImage.gif"));
                int type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
                BufferedImage resizeImageJpg = resizeImage(originalImage, type);
                ImageIO.write(resizeImageJpg, "gif", new File("FinalReSizedImage.gif"));
            }catch(Exception ex){
            }
        }catch(Exception ex){
        }
    }catch(Exception ex){
    }
}
    
public void printComponenet(final Component component){
  PrinterJob pj = PrinterJob.getPrinterJob();
  pj.setJobName("Print Component");

  pj.setPrintable (new Printable() {    
    public int print(Graphics pg, PageFormat pf, int pageNum){
      if (pageNum > 0){
      return Printable.NO_SUCH_PAGE;
      }

      Graphics2D g2 = (Graphics2D) pg;
      g2.translate(pf.getImageableX(), pf.getImageableY());
      component.paint(g2);
      return Printable.PAGE_EXISTS;
    }
  });
  if (pj.printDialog() == false)
  return;

  try {
        pj.print();
  } catch (PrinterException ex) {
        // handle exception
  }
}

public static BufferedImage rotateCw( BufferedImage img )
{
    int         width  = img.getWidth();
    int         height = img.getHeight();
    BufferedImage   newImage = new BufferedImage( height, width, img.getType() );

    for( int i=0 ; i < width ; i++ )
        for( int j=0 ; j < height ; j++ )
            newImage.setRGB( height-1-j, i, img.getRGB(i,j) );

    return newImage;
}

//for enlarging the image// this has yet to work. // not working yet
public static BufferedImage enlarge(BufferedImage image, int n) {

       int w = n*image.getWidth();
       int h = n*image.getHeight();

       BufferedImage enlargedImage = new BufferedImage(w, h, image.getType());
        
       for (int y=0; y < h; ++y){
           for (int x=0; x < w; ++x){
               enlargedImage.setRGB(x, y, image.getRGB(x/n, y/n));
           }
       }
        
       return enlargedImage;
   }

// below code is collected from https://www.mkyong.com/java/how-to-resize-an-image-in-java/ 
private static BufferedImage resizeImage(BufferedImage originalImage, int type){
    float W = Math.round(0.75 * originalImage.getWidth());
    float H = Math.round(0.75 * originalImage.getHeight());
    int IMG_WIDTH = (int) W;
    int IMG_HEIGHT = (int) H; 
	BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
	Graphics2D g = resizedImage.createGraphics();
	g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
	g.dispose();
		
	return resizedImage;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        footPanel = new javax.swing.JPanel();
        clearScreen = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuPrint = new javax.swing.JMenu();
        jMenuItemPrint = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(analyzervideofoot.AnalyzerVideoFootApp.class).getContext().getResourceMap(CIFforFootSizeMeasurement2.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("Form"); // NOI18N

        footPanel.setBackground(resourceMap.getColor("footPanel.background")); // NOI18N
        footPanel.setName("footPanel"); // NOI18N

        javax.swing.GroupLayout footPanelLayout = new javax.swing.GroupLayout(footPanel);
        footPanel.setLayout(footPanelLayout);
        footPanelLayout.setHorizontalGroup(
            footPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 416, Short.MAX_VALUE)
        );
        footPanelLayout.setVerticalGroup(
            footPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 244, Short.MAX_VALUE)
        );

        clearScreen.setFont(resourceMap.getFont("clearScreen.font")); // NOI18N
        clearScreen.setText(resourceMap.getString("clearScreen.text")); // NOI18N
        clearScreen.setName("clearScreen"); // NOI18N
        clearScreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearScreenActionPerformed(evt);
            }
        });

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenuPrint.setText(resourceMap.getString("jMenuPrint.text")); // NOI18N
        jMenuPrint.setName("jMenuPrint"); // NOI18N

        jMenuItemPrint.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemPrint.setText(resourceMap.getString("jMenuItemPrint.text")); // NOI18N
        jMenuItemPrint.setName("jMenuItemPrint"); // NOI18N
        jMenuItemPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPrintActionPerformed(evt);
            }
        });
        jMenuPrint.add(jMenuItemPrint);

        jMenuBar1.add(jMenuPrint);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(footPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(145, 145, 145)
                .addComponent(clearScreen, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                .addGap(144, 144, 144))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(footPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(clearScreen, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    private void clearScreenActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
      cidp.revalidate();
      cidp.repaint();
    }                                           

    private void jMenuItemPrintActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
    /*        // TODO add your handling code here:
    Toolkit tkp = cidp.getToolkit();
    PrintJob pjp = tkp.getPrintJob(this, null, null);
    Graphics g = pjp.getGraphics();
    cidp.print(g);
    g.dispose();
    pjp.end();
    */
        try{
            takeSnapShot(footPanel);
            printComponenet(footPanel);
        } 
        catch(Exception e){}
        
    }                                              

    /**
     * @param args the command line arguments
     */
   /*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CIFforFootSizeMeasurement2().setVisible(true);
            }
        });
    }
    */
    // Variables declaration - do not modify                     
    private javax.swing.JButton clearScreen;
    private javax.swing.JPanel footPanel;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItemPrint;
    private javax.swing.JMenu jMenuPrint;
    // End of variables declaration                   
}
Print and Printable image resize option