2
하나의 tiff 이미지를 열려면 아래 코드를 작성했습니다. 사실 저는 java 응용 프로그램 중 하나에서 imageJ (ImagePlus) 라이브러리를 사용하려고합니다. 하지만 오류 메시지가 나타납니다.ImageJ 라이브러리에서 tiff 이미지를 열지 못했습니다.
"이런 식 (4)에서 압축 ImageJ에 열 수 없습니다 TIFF 파일은"
는 어떤 도움을 크게 감상 할 수있다.
패키지 com.csc
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.imageio.*;
//import javax.imageio.ImageIO;
import ij.ImagePlus;
public class GetPixelCoordinates {
//int y, x, tofind, col;
/**
* @param args the command line arguments
* @throws IOException
*/
public static void main(String args[]) throws IOException {
try {
//read image file
ImagePlus img = new ImagePlus("C:\\javaCode\\TestIJ\\check_1.tiff");
//write file
FileWriter fstream = new FileWriter("C:\\javaCode\\TestIJ\\log.txt");
BufferedWriter out = new BufferedWriter(fstream);
//find cyan pixels
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int c[] = img.getPixel(x,y);
// Color color = new Color()
int redValue = c[0];
int greenValue = c[1];
int blueValue = c[2];
if (redValue < 30 &&greenValue >= 225 && blueValue >= 225) {
out.write("CyanPixel found at=" + x + "," + y);
out.newLine();
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
TIFF는 서로 다른 압축 포맷을 사용하며,이 하나가 (어쩌면 "특별한"하나?) 하나를 사용하는 것 같아 ImageJ에 의해 지원되지 않습니다. 이미지가 하나 뿐인 경우 이미지 조작 프로그램으로 열어 다른 압축으로 저장할 수 있습니다. 이미지가 여러 (많은) 이미지 인 경우 일괄 변환을 고려하거나이 특정 형식을 지원하는 TIFF 로더를 찾으십시오. – Marco13