Is it possible to create an image with a defined number of pixels? For example, create a circle through the equation x ^ 2 + y ^ 2 <= 200 ^ 2 in a 400x400 pp image and define different colors for points inside and outside of the circle.
Thanks
Using the equation explicitly,
img1 = Image[Table[
If[x^2 + y^2 > 200^2, Yellow, Red],
{x, -200, 200}, {y, -200, 200}],
ImageSize -> {400, 400}]
Or, using graphics primatives
img2 = Graphics[{
Yellow, Rectangle[{-200, -200}, {200, 200}],
Red, Disk[{0, 0}, 200]},
ImageSize -> {400, 400}]
i use the followings instructions:
emptyImage = Image[Table[0, {i, 1, 300}, {j, 1, 300}]]
NewImage = emptyImage;
For[i = 1, i < 300 + 1, i++,
For[j = 1, j < 300 + 1, j++,
If[(i - 150)^2 + (j - 150)^2 <= 300^2/4,
NewImage = ReplacePixelValue[NewImage, {i, j} -> 1];
]
]]
It is a bit slow but it works perfectly.