imgdiffhttps://api.pixlab.io/imgdiff
Description
Compute the difference between two images using the mean square error metric and optionally return the reconstructed image. Note that the two images must be exactly of the same width & height. Call resize or crop before to fit your images to the same dimension if any.
HTTP Methods
GET
Request Parameters
Required
Fields | Type | Description |
---|---|---|
src | URL | Source image URL. If you want to upload your image directly from your app, call store before invoking this one and use the output link. |
target | URL | Target image to compare to. Again, call store if you want to upload an image directly and use the output link. |
key | String | Your PixLab API Key. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to. |
Optional
Fields | Type | Description |
---|---|---|
blob | Boolean | By default, this command return a JSON object holding the link to the reconstructed image. But, if this parameter is set to true then the reconstructed image binary contents is returned instead. |
Response
application/json if the optional blob parameter is not set.
This command return a JSON object after each call only if the optional blob parameter is not set. Otherwise the reconstructed image binary contents is returned instead. The following are the JSON fields returned in response body:
Fields | Type | Description |
---|---|---|
status | Integer | Status code 200 indicates success, any other code indicates failure. |
link | URL | Link to the media output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard on how to do that). |
diff | Float | Computed difference between the two images. |
id | String | Unique media ID. |
error | String | Error message if status != 200. |
Python Example
import requests
import json
# Compute the difference between two images and output the reconstructed image and the diff output.
# Keep in mind that the two images must be of the same size or call 'resize' or 'crop' before to
# fit the images to the same dimension.
src = 'https://pixlab.io/images/jdr.jpg' # Source image which is the famous Michael Jordan's crying face.
target = 'https://pixlab.io/images/jdr_draw.jpg' # Target image which is the same Jordan's face but a MEME is drawn on top of it.
req = requests.get('https://api.pixlab.io/imgdiff',params={
'src': src,
'target': target,
'key':'My_Key'
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print ("Diff Output: "+str(reply['diff']))
print ("Reconstructed image link: "+ reply['link'])
See Also
header, nsfw, sfw, ocr, facedetect, facelandmarks, tagimg, crop, mogrify, facemotion, facelookup, facegenerate, screencapture