あなたはScript.LaunchOptions
クラスを使用することができます。
このクラスを使用すると、カーネルの実行の制限を設定できます。
例:あなたは(そう、2次元で)、X -indexで始まる(0ベース、含む)データ3
の「長方形」にカーネルを実行すると、xで終わります-index 8
(排他的)と、制限は11
と22
あるY側:
Script.LaunchOptions launchOptions;
launchOptions = new Script.LaunchOptions();
launchOptions.setX(3, 8);
launchOptions.setY(11, 22);
// Kernel run
myScript.forEach_myKernelName(inAlloc, outAlloc, launchOptions);
例:あなたが3ピクセル幅の境界線で、画像上にカーネルを適用します(例は直接FASTExampleサンプルプロジェクト):
Script.LaunchOptions fastLaunchOptions;
fastLaunchOptions = new Script.LaunchOptions();
fastLaunchOptions.setX(3, inputImageSize.width - 3);
fastLaunchOptions.setY(3, inputImageSize.height - 3);
// ...
scriptCFast.forEach_fastOptimized(
grayAllocation, fastKpAllocation, fastLaunchOptions);
例:
// Define the convolution
ScriptIntrinsicConvolve3x3 convolve3x3 =
ScriptIntrinsicConvolve3x3.create(mRS, Element.RGBA_8888(mRS));
// Some coefficients
float[] coefficients = {
0.7f, 0, 0.5f,
0, 1.0f, 0,
0.5f, 0, 1.0f
};
convolve3x3.setCoefficients(coefficients);
// Execute the allocation with limits
Script.LaunchOptions launchOptions;
launchOptions = new Script.LaunchOptions();
launchOptions.setX(3, 8);
launchOptions.setY(11, 22);
convolve3x3.setInput(inputAllocation);
convolve3x3.forEach(convolvedAllocation, launchOptions);
注:あなたが制限された範囲にわたりScriptIntrinsicConvolve3x3
カーネルを適用するこのプロセスは、単に特定の範囲に渡ってカーネルを実行し、新しい、より小さい割り当てを作成するつもりはありません。
scriptC_main.set_inputAllocation(convolvedAllocation);
scriptC_main.set_inputOffsetX(offsetX);
scriptC_main.set_inputOffsetY(offsetY);
scriptC_main.forEach_copyAllocation(outputAllocation);
編集:で呼び出さ
// Store the input allocation
rs_allocation inputAllocation;
// Offset indices, which define the start point for
// the copy in the input allocation.
int inputOffsetX;
int inputOffsetY;
uchar4 __attribute__((kernel)) copyAllocation(int x, int y) {
return rsGetElementAt_uchar4(
inputAllocation, x + inputOffsetX, y + inputOffsetY);
}
:だから、一定の制限上のカーネルを実行した後、次のようなコピーのカーネルを使用して、その結果をコピーする必要がありますI具体的にはexampleが作成され、次のプロセスが表示されます。
- データセットの制限付き畳み込みの実行。
- 畳み込み出力の新しい割り当てへのコピー。
参考:RenderScript: parallel computing on Android, the easy way
cmaster11 @あなたはそれを助けてくださいことができますか? – Shahryar
@LarrySchieferできればそれを手伝ってもらえますか?あなたは、私がstackoverflowでレンダスクリプトの質問に答える数少ない人の一人です。 – Shahryar
通知ありがとうございました:P – cmaster11