1

I have image in C# and I created array of that but for filtering and mask the picture I need 2 dimensional Array of image thank for your help!

2
  • Can you show how you have created a mono dimensional array from your image? Please tell us more also about what image format you are using. Commented Feb 6, 2011 at 23:25
  • Do the inverse of this? stackoverflow.com/questions/638701/… Commented Feb 6, 2011 at 23:31

1 Answer 1

1

Creating a 2d array from your image, or from your 1d array, is pretty straightforward. Here is the way to do it from your 1d array, although this can be easily translated directly to your image code:

int[][] To2dArray(int[] source, int width) 
{
    int height = source.Length / width;
    int[][] result = new int[height][width];
    for(int i = 0; i < height; i++)
    {
        for(int j = 0; j < width; j++)
        {
            result[i][j] = source[i * width + j];
        }
    }
    return result;
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.