A small addition (foot length measuring tool) to the Pedograph Software
by ahmad2005 on August 8, 2018
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.
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);
// 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;
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();