Replies: 1 comment 2 replies
-
It does make sense! In your case it is simpler because you already define the size of the picture in the circuit definition I haven't run your example, but for now it looks good to me. If there is a compile/solver error, then it would help if you have a full running example which I could try out. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Basically, the code below in a define function for a circuit.
The final 3 lines are the important bit, I'm (a) iterating over y & x, and (b) accessing pixels at locations [newXFr.(int)][newYFr.(int)], to (c) set the individual RGB values.
Similarly, I'm accessing a 2D array at this line:
currentPixel := oldImage.Pixels[x][y]
FYI "oldImage" and cropArea are both secret variables.
My question is: In general, or using this example, does it make sense in a circuit's define function to access a 2D array (i.e. the 2D array of pixels in this context) using a forloop like this? How would I go about setting/getting pixels in a 2D array, in an iterative manner? Thanks in advance!
Here's some extra context, please let me know if you need more info about this:
const (
N = 16
)
type CropCircuit struct {
PublicKey eddsa.PublicKey
gnark:",public"
ImageSignature eddsa.Signature
gnark:",public"
// Digital signature as eddsa.SignatureImageBytes frontend.Variable // z_in as Big Endian
FrImage myImage.FrontendImage // z_in as a FrontendImage
CroppedImage_in myImage.FrontendImage // Cropped previous image as a FrontendImage
Params CropParams // Crop transformation parameters
}
type ImageArea struct {
topLeft FrLocation
bottomRight FrLocation
}
type FrLocation struct {
X frontend.Variable
Y frontend.Variable
}
// An image with frontend pixels
type FrontendImage struct {
Pixels [N][N]FrontendPixel
}
// Frontend pixels are made up of frontend.Variable instead of uint8.
// These pixels can be manipulated in a PCD circuit.
type FrontendPixel struct {
R frontend.Variable
G frontend.Variable
B frontend.Variable
}
Beta Was this translation helpful? Give feedback.
All reactions