numpy向量化函数接收像素的r,g,b值

问题描述

我有一个功能

def co(pixel):
    print(pixel)
    #return [res]
    return pixel

我正在尝试用此方法转换3d数组:

v = np.vectorize(co)
#v.excluded.add(1)

new_arr = v(arr)

print(new_arr)

但是有趣的是,它可以打印出每个像素的r,g,b值。取而代之的是,它不应该打印像素吗?

我真正的问题是如何遍历图像中的所有像素并应用此变换。

最初我的图像看起来像这样:

[[[239 255 138]
  [239 255 138]
  [239 255 138]
  ...

解决方法

这是您遍历3-D矩阵的方式。 让我知道您是否要对图像应用水平(水平,垂直)滤镜

public void clickBusiness(View view) {
    checkPermsOfStorage( this );

    bizname = (EditText) findViewById( R.id.editBizName );
    item = (EditText) findViewById( R.id.editItem );
    price = (EditText) findViewById( R.id.editPrice );
    tax = (EditText) findViewById( R.id.editTax );
    total = (EditText) findViewById( R.id.editTotal );
    String x = ("\nItem/Price: " + item.getText() + price.getText() + "\nTax/Total" + tax.getText() + total.getText());
    Toast.makeText( this,x,Toast.LENGTH_SHORT ).show();
    try {
        this.WriteBusiness(bizname,storeno,rcpt,item,price,tax,total);
        String vv = tax.getText().toString();
        System.console().printf( "%s",vv );
        //new XMLDivisionWriter(getString(R.string.SDDoc) + "/tax_div_business.xml");
    } catch (ReflectiveOperationException e) {
        e.printStackTrace();
    }
}