私はJavaとimageJが初めてです。既に 1 つの画像を読み込んでおり、imgprocと呼ばれる ImageProcessor を取得しています。そして、画像内に特徴を囲む境界/ボックスを見つけました。ちょうど背景の外側。この領域のピクセル マトリックスも見つかりました。現在、画像のこの領域のみを処理しようとしています。以前の既存のコード (メソッド) でそれを行うには、入力パラメーターを ImageProcessor にする必要があります。したがって、私の最初の考えは、 duplicate() メソッドを使用してimgprocのコピーを作成することです。そして、サイズ変更メソッドを使用して、以前に見つけたボックスのサイズに縮小します。しかし、これは機能しませんでした。表示する必要がある show image メソッドでテストしたためです。私が得たのは、縮小された黒い写真です。この最初の考えは、ここにコード化されています。
ImageProcessor Whiteimproc=imgproc.duplicate();
ImageProcessor BWhiteimproc=Whiteimproc.resize(BWhiteMatrix.length,BWhiteMatrix[0].length);
BWhiteimproc.setIntArray(BWhiteMatrix);
//the next three lines are going to show the image
Image ImagetoShow=BWhiteimproc.createImage();
Img ShowImg= new Img();
ShowImg.imgFrame(ImagetoShow,"BWhite");`
次に、ImagePlus を使用して、新しい ImageProcessor を作成しようとしました。そして、それはうまくいきました。以下に示すように:
ImagePlus imgWhite=IJ.createImage("white","jpg",BWhiteMatrix.length,BWhiteMatrix[0].length,1);
ImageProcessor BWhiteimproc=imgWhite.getProcessor();
BWhiteimproc.setIntArray(BWhiteMatrix);
//the next three lines are going to show the image
Image ImagetoShow=BWhiteimproc.createImage();
Img ShowImg= new Img();
ShowImg.imgFrame(ImagetoShow,"BWhite");
それがなぜなのか、誰かが私を助けてくれますか?そして、ImageProcessor を使用して ImageProcessor クラスの新しいオブジェクトを定義できなかった理由を知っています。
ありがとう