1

I'm beginning a computer vision project and I need to compute the horizontal and vertical Sobel's derivatives. I'm using Python together with Numpy and Scipy, specifically the ndimage.filters module.

I can't understand the difference between the return value and the output parameter.

   output_x = np.zeros(image.shape)
   output_y = np.zeros(image.shape)
   filters.sobel(image, 1, output_x)
   filters.sobel(image, 0, output_y)

   return_val_1 = filters.sobel(image, axis=1)
   return_val_2 = filters.sobel(image, axis=0)

If I plot the return values images and the outputs images I get different results. Why? Can you please help me? I'm quiet confused.

4

2 に答える 2

0

問題はデータ型です。

_ni_support._get_outuptdo はnp.zeros(input.shape, input.dtype.name)で、はinput.dtype.nameuint8 です。あなたがしたことはnp.zeros(input.shape)、デフォルトのデータ型はfloatです。

私は同じ問題に遭遇し、ソースコードを確認して理解しました。

于 2017-01-06T01:38:48.823 に答える
0

出力配列を渡すと、新しい配列を作成する代わりに、その配列に結果が格納されます。

これは、メモリを節約するためにインプレースで操作する必要がある場合に非常に便利です。

配列を指定するoutputと、ndimage 関数は を返しNoneます。それ以外には、違いはありません。

于 2012-06-18T15:09:21.817 に答える