I have a large single dimension array ful of Zmap data (ea height data) the array is quite huge it consists of 100 measurements samples of an area pixel. I need to process it in several ways, so that another locked bitmap can be corrected. To speed up to processing of this large array I make use of parallel.for
ea:
public void MarkErrorSamples(int[]Depthdata,int lowbound)
{
Parallel.For (0, depthData.Length, sampleN =>
{
if(depthData[sampleN] < lowbount)
{
// update redchannel Red value by 20
int x= xfromLockedmemPos(sampleN); // x value based upon sampleN
int y =yfromLockedmemPos(sampleN);
setpixel(x,y,AddRed((getpixelRed(x,y),20);
}
});
}
The above code works but I have some doubts about accessing the depthdata[sampleN]
the way I do it now. My concern here is that I think the threads might lock the array with each time a thread is launched to retrieve data from it. So I wonder is above the correct way to work with a 'external block' array data in an Parallel.for
Note that in the above void it is not required change the depthdata itself, only perform action on bitmap (making use of a lockbits bitmap).