Coordinate of matching pixel on texture

So I’m using GetPixels on a Texture2D to get a Color array of pixels.

I loop through the pixels in the array, checking against a color I want to search for, and setting it to transparent (0,0,0,0), then return it.

Texture2D RemoveColor(Color c, Texture2D imgs){		
	Color[] pixels = imgs.GetPixels(0, 0, imgs.width, imgs.height, 0);
            for(int p = 0; p < pixels.Length; p++){ 
                   if(pixels[p].r == c.r && pixels[p].g == c.g){ 
				Debug.Log (p);
				pixels[p] = new Color(0,0,0,0);	    			
			   	 }
            }	 		
		imgs.SetPixels(0, 0, imgs.width, imgs.height, pixels, 0);
		imgs.Apply ();
		return imgs;
		}	

Now when I debug ‘p’ I get numbers like 123,222, so pixels[123222] will be transparent and is the one I want to monitor, but is there any way to figure out what the x,y position would be on the screen if the texture filled the screen, based off knowing which pixel index in a byte array you want to find, and how many there are total in the array???

I was thinking about adding the matching pixels to another array the same size as the original texture’s array rather than setting them transparent, and somehow utilize them from there but it all comes down to the same problem of translating it into x,y coordinates.

Just divide the index number by the width to get the y, and the remainder is the x. By the way, it’s better to use GetPixels32 and SetPixels32 (faster, 4X less RAM usage).

Color pixels = texture.GetPixels();

for (int i = 0; i < pixels.Length; i++)
{
    int x = i % texture.width;
    int y = i / texture.width;

    Vector2 coords01 = new Vector2(
        (float)x / (texture.width - 1),
        (float)y / (texture.height - 1));

    // Debug
    /*
    Color cA = texture.GetPixel(x, y);
    Color cB = pixels*;*

if (cA != cB)
{
Debug.LogError("i: " + i + " x: " + x + " y: " + y);
break;
}
*/
}