Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing java.io.FileNotFoundException:对Image.io.write的访问被拒绝_Image Processing_Filenotfoundexception_Access Denied - Fatal编程技术网

Image processing java.io.FileNotFoundException:对Image.io.write的访问被拒绝

Image processing java.io.FileNotFoundException:对Image.io.write的访问被拒绝,image-processing,filenotfoundexception,access-denied,Image Processing,Filenotfoundexception,Access Denied,Im在4x8和8x16网格中裁剪64x128像素的图像,并将其保存在临时文件夹中,以便从中提取特征以进行图像分类。当我在多个图像的循环中执行此操作时(我裁剪第一个图像,获取8x16子图像,提取每个子图像的特征,移动到下一个图像并覆盖现有子图像),我在随机网格单元中得到一个“未找到文件”异常,因为对所述网格单元的访问被拒绝。这仅在处理大量(比如20+)图像时发生。我怎样才能解决这个问题 裁剪部分的我的代码: package imageProcess; import java.awt.image.

Im在4x8和8x16网格中裁剪64x128像素的图像,并将其保存在临时文件夹中,以便从中提取特征以进行图像分类。当我在多个图像的循环中执行此操作时(我裁剪第一个图像,获取8x16子图像,提取每个子图像的特征,移动到下一个图像并覆盖现有子图像),我在随机网格单元中得到一个“未找到文件”异常,因为对所述网格单元的访问被拒绝。这仅在处理大量(比如20+)图像时发生。我怎样才能解决这个问题

裁剪部分的我的代码:

package imageProcess;

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

import javax.imageio.ImageIO;

public class Crop_Raster {

BufferedImage src;
BufferedImage dst;


public Crop_Raster(BufferedImage src) {
    super();
    this.src = src;
}

public void cropImage_4x8() throws IOException{
    int filenumber = 1;
    for (int y = 0;y<4;y++){
        for (int x = 0; x<8;x++){
            File output = new File("Temp/"+filenumber+".jpg");
            dst = src.getSubimage(16*x,16*y, 16, 16);   
            ImageIO.write(dst, "jpg", output);
            filenumber ++;
        }
    }
}

public void cropImage_8x16() throws IOException{
    int filenumber = 1;
    for (int y = 0;y<8;y++){
        for (int x = 0; x<16;x++){
            File output = new File("Temp/"+filenumber+".jpg");
            dst = src.getSubimage(8*x,8*y, 8, 8);   
            ImageIO.write(dst, "jpg", output);
            filenumber ++;
        }
    }
}
封装图像处理;
导入java.awt.image.buffereImage;
导入java.io.File;
导入java.io.IOException;
导入javax.imageio.imageio;
公共类裁剪光栅{
缓冲图像src;
缓冲图像dst;
公共裁剪光栅(BuffereImage src){
超级();
this.src=src;
}
public void cropImage_4x8()引发IOException{
int filenumber=1;

对于(int y=0;y在每个图像修复问题后清除临时文件夹)

java.io.FileNotFoundException: Temp\2.jpg (Zugriff verweigert)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(Unknown Source)
at java.io.RandomAccessFile.<init>(Unknown Source)
at javax.imageio.stream.FileImageOutputStream.<init>(Unknown Source)
at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(Unknown Source)
at javax.imageio.ImageIO.createImageOutputStream(Unknown Source)
at javax.imageio.ImageIO.write(Unknown Source)
at imageProcess.Crop_Raster.cropImage_8x16(Crop_Raster.java:38)
at svm.CreateVektor.createVector_8x16(CreateVektor.java:94)
at Main_Test.main(Main_Test.java:107)