2017-08-31 5 views
0

私はOpenCV 2.4.8を使ってJavaでスケールを掛けた各CV_8UC3カラーチャンネルの絶対差を計算しようとしています!Java Pixel Access OpenCv 2.4.8

私はその後、私が得たjavaはUCHAR使用していないことを知っていて、Javaで最も近い[]

文字列だと思ったしかし、それは動作しませんでしたので、私は短いの使用:

"error: cannot find symbol 
short[] ptr_entry = image_entry.<short>ptr(row); 
symbol: method <short>ptr(int) location: variable image_entry of type Mat 

私はatメソッドを使ってみる可能性を試しましたが、これをjavaで動かすことができませんでした!

for (int row = 0; row < image_entry.rows(); ++row) 
    { 
     short[] ptr_entry = image_entry.<short>ptr(row); 
     uchar[] ptr_compressed = image_compressed.<uchar>ptr(row); 
     uchar[] ptr_output = image_output.<uchar>ptr(row); 

     for (int col = 0; col < image_entry.cols(); col++) 
     { 
      // Calculation of the absolute difference in each color channel, multiplied by the scale 
      ptr_output[0] = Math.abs(ptr_entry[0] - ptr_compressed[0]) * scale; 
      ptr_output[1] = Math.abs(ptr_entry[1] - ptr_compressed[1]) * scale; 
      ptr_output[2] = Math.abs(ptr_entry[2] - ptr_compressed[2]) * scale; 

      ptr_entry += 3; 
      ptr_compressed += 3; 
      ptr_output += 3; 
     } 
    } 

どのような提案ですか?

答えて

0

ピクセルデータにアクセスするには、Mat.get()関数を使用します。

public int get(int row,int col, short[] data) 

OpenCV Java API documentationを読むと、不要な投稿を防ぐことができます。

+0

明日別にお渡しします!私は、OpenCVのJavaのドキュメントに欠けているものを見つけましたが、あなたの右の新しい目のペアが順調です! –

+0

OpenCV for Javaのピクセル値にアクセスするためのget()とput()の使用 –

+0

@TomCそれは素晴らしいです。 – zindarod