feat(v2): add multiple extra features from the pdf slides
This commit is contained in:
@@ -69,6 +69,16 @@ def histogram(image):
|
||||
return probabilities.round(8).tolist()
|
||||
|
||||
|
||||
def histogram_payload(image):
|
||||
gray = to_gray(image)
|
||||
payload = {"intensity": histogram(gray)}
|
||||
if image.ndim == 3:
|
||||
payload["r"] = (np.bincount(image[:, :, 0].ravel(), minlength=256).astype(np.float64) / image[:, :, 0].size).round(8).tolist()
|
||||
payload["g"] = (np.bincount(image[:, :, 1].ravel(), minlength=256).astype(np.float64) / image[:, :, 1].size).round(8).tolist()
|
||||
payload["b"] = (np.bincount(image[:, :, 2].ravel(), minlength=256).astype(np.float64) / image[:, :, 2].size).round(8).tolist()
|
||||
return payload
|
||||
|
||||
|
||||
def image_to_data_url(image):
|
||||
pil_image = Image.fromarray(ensure_uint8(image))
|
||||
buffer = BytesIO()
|
||||
|
||||
Reference in New Issue
Block a user