Java-Class (in welk programma moet ik doen openen)

Status
Niet open voor verdere reacties.

Bartjed2

Gebruiker
Lid geworden
19 mei 2009
Berichten
6
Hallo allemaal,

Dit ie het eerste bericht van mij en wil dus zeggen dat ik nieuw ben. Ik zit wel in de techniek maar programmeren van een programma is nog erg moeilijk. Een plc programmeer ik wel.

Mijn vraag is eigenlijk; ik heb een programma voor Java. Nu wil ik dit programma laten werken maar weet alleen niet hoe. Ik heb gehoord van Java Virtual maar snap het niet.
Ik heb hier beneden een stukje van het prog. staan Misschien zegt dit iemand iets.

Ik hoop dat iemand mij kan helpen. Al vast bedankt voor jullie moeite.

Gr Bart

import java.io.*;
import java.math.*;

/*
classProcess
-findNew
-lowPass
-greyScale
-edgeTrace

Contains methods for image manipulation.
*/
public class classProcess
{
public classProcess(){}

public final int WIDTH = 320;
public final int HEIGHT = 240;

public classPixelFunctions PF = new classPixelFunctions();


public boolean[][] howDifferent(int[][] inBackground, int[][] inFrame, int tolerance)
{
int[][] temp = new int[WIDTH][HEIGHT];
boolean[][] btemp = new boolean[WIDTH][HEIGHT];

for(int x=0; x<WIDTH; x+=2){for(int y=0; y<HEIGHT; y+=2){
temp[x][y]=Math.abs(inBackground[x][y]-inFrame[x][y]);
if(temp[x][y]<tolerance){btemp[x][y]=true;}

btemp[x+1][y]=btemp[x][y];btemp[x][y+1]=btemp[x][y];btemp[x+1][y+1]=btemp[x][y];
//temp[x+1][y]=temp[x][y];temp[x][y+1]=temp[x][y];temp[x+1][y+1]=temp[x][y];
}}

//for (int x=0; x<WIDTH; x++){btemp[x][0]=false;btemp[x][1]=false;btemp[x][(HEIGHT-1)]=false;btemp[x][(HEIGHT-2)]=false;}
//for (int y=0; y<HEIGHT; y++){btemp[0][y]=false;btemp[1][y]=false;btemp[(WIDTH-1)][y]=false;btemp[(WIDTH-2)][y]=false;}

return btemp;
}



//Return edges that are in a new place as white pixels.
public boolean[][] findNew(boolean[][] inLastFrame, boolean[][] inThisFrame)
{
boolean[][] tempArray = new boolean[WIDTH][HEIGHT];
for (int x=0; x<WIDTH; x++){for (int y=0; y<HEIGHT; y++) //For each pixel...
{
if(inThisFrame[x][y]==true && inLastFrame[x][y]==false) //if it's true and wasn't before
{tempArray[x][y]=false;} //Black!
else
{tempArray[x][y]=true;} //if not, White!
}}
return tempArray;
}

public int[][] greyScale3(long[][] inPixelArray) throws Exception
{
classPixelFunctions PF = new classPixelFunctions(); //Need the LongToX methods
int[][] temp = new int[WIDTH][HEIGHT];
for (int x=0; x<WIDTH; x+=2){for (int y=0; y<HEIGHT; y+=2) //For each pixel...
{
temp[x][y] = (int) (0.15 * PF.longToR2(inPixelArray[x][y]) + 0.55 * PF.longToG2(inPixelArray[x][y]) + 0.30 * PF.longToB2(inPixelArray[x][y]));
temp[x+1][y]=temp[x][y];temp[x][y+1]=temp[x][y];temp[x+1][y+1]=temp[x][y];
}}

return temp;
}

//Takes an array of long pixels, returns as an array of ints, by averaging the RGB of the longs:
public int[][] greyScale(long[][] inPixelArray) throws Exception
{
classPixelFunctions PF = new classPixelFunctions(); //Need the LongToX methods
int[][] tempArray = new int[WIDTH][HEIGHT]; //Now it'll be an int: a single RGB value
for (int x=0; x<WIDTH; x++){for (int y=0; y<HEIGHT; y++) //For each pixel...
{
//Average the RGB's and return as one grey:
tempArray[x][y] = (PF.longToR(inPixelArray[x][y]) + PF.longToG(inPixelArray[x][y]) + PF.longToB(inPixelArray[x][y]))/3;
}}

return tempArray;
}

//From an array of int pixels (greyscale image), return the vertical and horizontal edgetrace array:
//true pixels: found edge. (old 255)
//false pixels: found no edge. (old 0)
public boolean[][] edgeTrace(int[][] inPixelArray, int inTolerance) throws Exception
{
boolean[][] tempArray = new boolean[WIDTH][HEIGHT]; //What will be returned, black and white.
for(int x=0; x<(WIDTH-1); x++){for(int y=0; y<(HEIGHT-1); y++) //For each pixel, excluding the right and bottom edges.
{
//If the difference between the pixel and the one to the right and/or the bottom of it is greater than inTolerance.
if((Math.abs(inPixelArray[x][y]-inPixelArray[x+1][y]) > inTolerance) || (Math.abs(inPixelArray[x][y]-inPixelArray[x][y+1]) > inTolerance))
{tempArray[x][y]=true;} //Then make it white.
else
{tempArray[x][y]=false;} //Otherwise it's black.
}}
//Double black border
for (int x=0; x<WIDTH; x++){tempArray[x][0]=false;tempArray[x][1]=false;tempArray[x][(HEIGHT-1)]=false;tempArray[x][(HEIGHT-2)]=false;}
for (int y=0; y<HEIGHT; y++){tempArray[0][y]=false;tempArray[1][y]=false;tempArray[(WIDTH-1)][y]=false;tempArray[(WIDTH-2)][y]=false;}

return tempArray;
}

public boolean[][] edgeTrace2(int[][] inPixelArray, int inTolerance) throws Exception
{
boolean[][] tempArray = new boolean[WIDTH][HEIGHT]; //What will be returned, black and white.
for(int x=0; x<(WIDTH-1); x+=2){for(int y=0; y<(HEIGHT-1); y+=2)
{
//If the difference between the pixel and the one to the right and/or the bottom of it is greater than inTolerance.
if(Math.abs(inPixelArray[x][y]-inPixelArray[x+1][y]) > inTolerance)
{tempArray[x][y]=true;tempArray[x+1][y+1]=true;tempArray[x+1][y]=true;} //Then make it white.
if(Math.abs(inPixelArray[x][y]-inPixelArray[x][y+1]) > inTolerance)
{tempArray[x][y]=true;tempArray[x+1][y+1]=true;tempArray[x][y+1]=true;}

}}
//Double black border
for (int x=0; x<WIDTH; x++){tempArray[x][0]=false;tempArray[x][1]=false;tempArray[x][(HEIGHT-1)]=false;tempArray[x][(HEIGHT-2)]=false;}
for (int y=0; y<HEIGHT; y++){tempArray[0][y]=false;tempArray[1][y]=false;tempArray[(WIDTH-1)][y]=false;tempArray[(WIDTH-2)][y]=false;}

return tempArray;
}


}
 
Dit is geen complet programma, maar een (heel) klein onderdeel.

Als je wilt beginnen met java moet je eerst java downloaden

http://java.sun.com/javase/downloads/index.jsp

kies JDK + netbeans..

Netbeans is een programma waarmee je Java programma kan schrijven en testen
Op de netbeans site hebben zo ook tutorials staan.

Alvast een paar belangrijke termen:
JVM = java virtual machine, het programma dat je nodig hebt om een java programma te draaien)
JDK = java development kit, heb je alleen nodig als je zelf java programma wilt schrijven.
JAVA SE = Standard edition (voor desktop en Applets)...
JAVA EE = Enterprise edition (java voor website, client-server ed)

Succes...
 
Bedankt

Wauw zeg ik had niet gedacht dat dit zo moeilijk kon zijn. Ik heb het prog. gedownload maar snap er nog niet veel van.

Ik heb er wat mee gespeeld maar kom er niet uit.

Wie kan mij verder helpen. Wat moet ik doen als ik het programma heb opgestart?


Sorry maar ik ben een beginneling en ik zal veel geduld moeten hebben, maar alle hulp is mee genomen

Bedankt alvast Skinflowers Oja, de rest van heb ik ook, ik heb er maar een map van het programma hier neer gezet.

Bart
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan