How Can I Converting Byte* To Nativearray<byte>

Hello,

My code processing some images with OpenCVSharp.

looping (load → calculating the maximum value in each column → creating a 3D cube with the position of that pixel)

The 2nd procedure takes too much time. so I want to apply job system.

BTW, I have two questions.

  1. How can I convert byte* to NativeArray ?
    private unsafe void CalcMaxOnColumnParallel(Mat src, ref Mat dst)
    {
        byte max = 0;
        int x = 0;
        int y = 0;

        byte* srcData = (byte*)src.DataPointer;
        byte* dstData = (byte*)dst.DataPointer;
        var original = new NativeArray<byte>((src.Cols * src.Rows), Allocator.Persistent);

        original = srcData; // <------------------- I have no idea for this line.
      
        .....      

        for (x = 0; x < src.Cols; x++)
        {
            for (y = 0; y < src.Rows; y++)
            {
                if (srcData[(y * src.Cols) + x] >= max)
                {
                    max = srcData[(y * src.Cols) + x];
                }
            }

            for (y = 0; y < src.Rows; y++)
            {
                // extension
                if (srcData[(y * src.Cols) + x] >= (max * 0.75))
                {
                    dstData[(y * src.Cols) + x] = srcData[(y * src.Cols) + x];
                }
                else
                {
                    dstData[(y * src.Cols) + x] = 0;
                }
            }
            max = 0;
        }
     }
  1. I want to convert code bellow to IJobParallelFor, How should I write the code of parallel for?
    Should I make jobs for each column?
        for (x = 0; x < src.Cols; x++)
        {
            for (y = 0; y < src.Rows; y++)
            {
                if (srcData[(y * src.Cols) + x] >= max)
                {
                    max = srcData[(y * src.Cols) + x];
                }
            }

            for (y = 0; y < src.Rows; y++)
            {
                // extension
                if (srcData[(y * src.Cols) + x] >= (max * 0.9))
                {
                    dstData[(y * src.Cols) + x] = srcData[(y * src.Cols) + x];
                }
                else
                {
                    dstData[(y * src.Cols) + x] = 0;
                }
            }
            max = 0;
        }
var original = new NativeArray<byte>(srcData, Allocator.Persistent);