IplImage img;
IplImage grayImg=null;
for (File image : imageFiles) {
img = cvLoadImage(image.getAbsolutePath(),CV_BGR2GRAY);
int yer = image.getName().indexOf(".");
String isim=image.getName().substring(0,yer);
label = Integer.parseInt(isim);
images.put(counter, img);
labels[counter] = label;
counter++;
}
it is the final of my code and it works like a charm :)