update,
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_descriptor(file_path, image, num_blocks=8, resize_to_px=256):
|
||||||
|
"""
|
||||||
|
Compute the Color Layout Descriptor (CLD) of an image.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
image (numpy.ndarray): Input image
|
||||||
|
num_blocks (int, optional): Number of blocks to divide the image into. Defaults to 8.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
numpy.ndarray: CLD feature vector
|
||||||
|
"""
|
||||||
|
# Step 3: Resize image to a fixed size (we'll use 256x256 for simplicity)
|
||||||
|
resized_image = cv2.resize(image, (resize_to_px, resize_to_px))
|
||||||
|
# Save the resized image to a file
|
||||||
|
cv2.imwrite(
|
||||||
|
os.path.join(
|
||||||
|
os.path.join(
|
||||||
|
os.path.dirname(file_path),
|
||||||
|
os.path.splitext(os.path.basename(file_path))[0] + "_resized.jpg",
|
||||||
|
)
|
||||||
|
),
|
||||||
|
resized_image,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 4: Convert image to YCrCb color space
|
||||||
|
ycrcb_image = cv2.cvtColor(resized_image, cv2.COLOR_BGR2YCrCb)
|
||||||
|
|
||||||
|
# Step 5: Divide the image into sub-blocks
|
||||||
|
block_size = int(256 / num_blocks)
|
||||||
|
blocks = []
|
||||||
|
for i in range(num_blocks):
|
||||||
|
for j in range(num_blocks):
|
||||||
|
block = ycrcb_image[
|
||||||
|
i * block_size : (i + 1) * block_size,
|
||||||
|
j * block_size : (j + 1) * block_size,
|
||||||
|
]
|
||||||
|
blocks.append(block)
|
||||||
|
|
||||||
|
# Step 6: Extract features from each sub-block
|
||||||
|
features = []
|
||||||
|
for block in blocks:
|
||||||
|
# Compute the mean and standard deviation of each color channel
|
||||||
|
mean_y, mean_cr, mean_cb = np.mean(block, axis=(0, 1))
|
||||||
|
std_y, std_cr, std_cb = np.std(block, axis=(0, 1))
|
||||||
|
features.extend([mean_y, mean_cr, mean_cb, std_y, std_cr, std_cb])
|
||||||
|
|
||||||
|
# Step 7: Concatenate features into a single vector
|
||||||
|
cld_vector = np.array(features)
|
||||||
|
|
||||||
|
return cld_vector
|
@@ -0,0 +1,78 @@
|
|||||||
|
"""
|
||||||
|
Task:
|
||||||
|
implement a `Color_layout_descriptor` using python and openCV
|
||||||
|
plesae provide a example of usage as well, compare two images `image1.png` and `image2.png` using `color_layout_descriptor`
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
- imagine you are writing a python program to a junior developer
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
- please solve it step by step
|
||||||
|
- Divide the whole image into sub-blocks.
|
||||||
|
- Extract features from each sub-block.
|
||||||
|
- name of function "color_layout_hellowold"
|
||||||
|
- please make sure your code is clean and readable
|
||||||
|
- please write detalied comment
|
||||||
|
- please make your code testable
|
||||||
|
- please review your code before return to the developer
|
||||||
|
- with `Zigzag scanning`
|
||||||
|
|
||||||
|
Reference:
|
||||||
|
https://en.wikipedia.org/wiki/Color_layout_descriptor
|
||||||
|
"""
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
import sys
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
from task1.src.tutorial1.color_layout_descriptor.color_layout_descriptor import color_layout_descriptor
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_hello_world(image1_path, image2_path, block=8, resize_to_px=256):
|
||||||
|
"""
|
||||||
|
Compare two images using the Color Layout Descriptor.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
image1_path (str): Path to the first image
|
||||||
|
image2_path (str): Path to the second image
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: Similarity score between the two images
|
||||||
|
"""
|
||||||
|
image1 = cv2.imread(image1_path)
|
||||||
|
image2 = cv2.imread(image2_path)
|
||||||
|
|
||||||
|
cld1 = color_layout_descriptor(image1_path, image1, block, resize_to_px)
|
||||||
|
cld2 = color_layout_descriptor(image2_path, image2, block, resize_to_px)
|
||||||
|
|
||||||
|
# Compute the Euclidean distance between the two CLD vectors
|
||||||
|
distance = np.linalg.norm(cld1 - cld2)
|
||||||
|
|
||||||
|
# Convert the distance to a similarity score (lower values indicate higher similarity)
|
||||||
|
similarity = 1 / (1 + distance)
|
||||||
|
|
||||||
|
return similarity
|
||||||
|
|
||||||
|
|
||||||
|
beach_1_jpg = "beach/image1.jpg"
|
||||||
|
beach_2_jpg = "beach/beach_2.jpg"
|
||||||
|
beach_138_jpg = "beach/138.jpg"
|
||||||
|
bus_jpg = "bus/357.jpg"
|
||||||
|
|
||||||
|
for test_block in [8]:
|
||||||
|
for r_px in [256]:
|
||||||
|
print("-" * 80)
|
||||||
|
print("using b:", test_block, "r:", r_px)
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_1_jpg, test_block, r_px)
|
||||||
|
print(f"diff beach_1 loopback (expected same = 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_2_jpg, test_block, r_px)
|
||||||
|
print(f"diff beach_1 beach_2 (expected similar ~ 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_138_jpg, test_block, r_px)
|
||||||
|
print(f"diff beach_1 beach_138_jpg (expected same ~ 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, bus_jpg, test_block, r_px)
|
||||||
|
print(f"diff beach_1 bus_jpg (expected different ~ 0) : {similarity:.4f} ({abs(0-similarity):.4f})")
|
@@ -0,0 +1,127 @@
|
|||||||
|
"""
|
||||||
|
Task:
|
||||||
|
implement a `Color_layout_descriptor` using python and openCV
|
||||||
|
plesae provide a example of usage as well, compare two images `image1.png` and `image2.png` using `color_layout_descriptor`
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
- imagine you are writing a python program to a junior developer
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
- please solve it step by step
|
||||||
|
- Divide the whole image into sub-blocks.
|
||||||
|
- Extract features from each sub-block.
|
||||||
|
- name of function "color_layout_hellowold"
|
||||||
|
- please make sure your code is clean and readable
|
||||||
|
- please write detalied comment
|
||||||
|
- please make your code testable
|
||||||
|
- please review your code before return to the developer
|
||||||
|
- with `Zigzag scanning`
|
||||||
|
|
||||||
|
Reference:
|
||||||
|
https://en.wikipedia.org/wiki/Color_layout_descriptor
|
||||||
|
"""
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
import os, sys
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_descriptor(file_path, image, num_blocks=8):
|
||||||
|
"""
|
||||||
|
Compute the Color Layout Descriptor (CLD) of an image.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
image (numpy.ndarray): Input image
|
||||||
|
num_blocks (int, optional): Number of blocks to divide the image into. Defaults to 8.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
numpy.ndarray: CLD feature vector
|
||||||
|
"""
|
||||||
|
# Step 3: Resize image to a fixed size (we'll use 256x256 for simplicity)
|
||||||
|
resized_image = cv2.resize(image, (256, 256))
|
||||||
|
# Save the resized image to a file
|
||||||
|
cv2.imwrite(
|
||||||
|
os.path.join(
|
||||||
|
os.path.join(
|
||||||
|
os.path.dirname(file_path),
|
||||||
|
os.path.splitext(os.path.basename(file_path))[0] + "_resized.jpg",
|
||||||
|
)
|
||||||
|
),
|
||||||
|
resized_image,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 4: Convert image to YCrCb color space
|
||||||
|
ycrcb_image = cv2.cvtColor(resized_image, cv2.COLOR_BGR2YCrCb)
|
||||||
|
|
||||||
|
# Step 5: Divide the image into sub-blocks
|
||||||
|
block_size = int(256 / num_blocks)
|
||||||
|
blocks = []
|
||||||
|
for i in range(num_blocks):
|
||||||
|
for j in range(num_blocks):
|
||||||
|
block = ycrcb_image[
|
||||||
|
i * block_size : (i + 1) * block_size,
|
||||||
|
j * block_size : (j + 1) * block_size,
|
||||||
|
]
|
||||||
|
blocks.append(block)
|
||||||
|
|
||||||
|
# Step 6: Extract features from each sub-block
|
||||||
|
features = []
|
||||||
|
for block in blocks:
|
||||||
|
# Compute the mean and standard deviation of each color channel
|
||||||
|
mean_y, mean_cr, mean_cb = np.mean(block, axis=(0, 1))
|
||||||
|
std_y, std_cr, std_cb = np.std(block, axis=(0, 1))
|
||||||
|
features.extend([mean_y, mean_cr, mean_cb, std_y, std_cr, std_cb])
|
||||||
|
|
||||||
|
# Step 7: Concatenate features into a single vector
|
||||||
|
cld_vector = np.array(features)
|
||||||
|
|
||||||
|
return cld_vector
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_hello_world(image1_path, image2_path, block=8):
|
||||||
|
"""
|
||||||
|
Compare two images using the Color Layout Descriptor.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
image1_path (str): Path to the first image
|
||||||
|
image2_path (str): Path to the second image
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: Similarity score between the two images
|
||||||
|
"""
|
||||||
|
image1 = cv2.imread(image1_path)
|
||||||
|
image2 = cv2.imread(image2_path)
|
||||||
|
|
||||||
|
cld1 = color_layout_descriptor(image1_path, image1, block)
|
||||||
|
cld2 = color_layout_descriptor(image2_path, image2, block)
|
||||||
|
|
||||||
|
# Compute the Euclidean distance between the two CLD vectors
|
||||||
|
distance = np.linalg.norm(cld1 - cld2)
|
||||||
|
|
||||||
|
# Convert the distance to a similarity score (lower values indicate higher similarity)
|
||||||
|
similarity = 1 / (1 + distance)
|
||||||
|
|
||||||
|
return similarity
|
||||||
|
|
||||||
|
|
||||||
|
beach_1_jpg = "image1.jpg"
|
||||||
|
beach_2_jpg = "beach_2.jpg"
|
||||||
|
bus_jpg = "357.jpg"
|
||||||
|
beach_138_jpg = "138.jpg"
|
||||||
|
|
||||||
|
for test_block in range(1, 16 + 1, 1):
|
||||||
|
print("-" * 80)
|
||||||
|
print("using test_block: ", test_block)
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_1_jpg, test_block)
|
||||||
|
print(f"diff beach_1 loopback (expected same = 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_2_jpg, test_block)
|
||||||
|
print(f"diff beach_1 beach_2 (expected similar ~ 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, beach_138_jpg, test_block)
|
||||||
|
print(f"diff beach_1 beach_138_jpg (expected same ~ 1) : {similarity:.4f} ({abs(1-similarity):.4f})")
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(beach_1_jpg, bus_jpg, test_block)
|
||||||
|
print(f"diff beach_1 bus_jpg (expected different ~ 0) : {similarity:.4f} ({abs(0-similarity):.4f})")
|
@@ -0,0 +1,91 @@
|
|||||||
|
"""
|
||||||
|
Task:
|
||||||
|
implement a `Color_layout_descriptor` using python and openCV
|
||||||
|
plesae provide a example of usage as well, compare two images `image1.png` and `image2.png` using `color_layout_descriptor`
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
- imagine you are writing a python program to a junior developer
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
- please solve it step by step
|
||||||
|
- Divide the whole image into sub-blocks.
|
||||||
|
- Extract features from each sub-block.
|
||||||
|
- name of function "color_layout_hellowold"
|
||||||
|
- please make sure your code is clean and readable
|
||||||
|
- please write detalied comment
|
||||||
|
- please make your code testable
|
||||||
|
- please review your code before return to the developer
|
||||||
|
- with `Zigzag scanning`
|
||||||
|
|
||||||
|
Reference:
|
||||||
|
https://en.wikipedia.org/wiki/Color_layout_descriptor
|
||||||
|
"""
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
import os, sys
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_descriptor(image, num_blocks=8, resize_to_px=256):
|
||||||
|
resized_image = cv2.resize(image, (resize_to_px, resize_to_px))
|
||||||
|
|
||||||
|
# Step 4: Convert image to YCrCb color space
|
||||||
|
ycrcb_image = cv2.cvtColor(resized_image, cv2.COLOR_BGR2YCrCb)
|
||||||
|
|
||||||
|
# Step 5: Divide the image into sub-blocks
|
||||||
|
block_size = int(256 / num_blocks)
|
||||||
|
blocks = []
|
||||||
|
for i in range(num_blocks):
|
||||||
|
for j in range(num_blocks):
|
||||||
|
block = ycrcb_image[
|
||||||
|
i * block_size : (i + 1) * block_size,
|
||||||
|
j * block_size : (j + 1) * block_size,
|
||||||
|
]
|
||||||
|
blocks.append(block)
|
||||||
|
|
||||||
|
# Step 6: Extract features from each sub-block
|
||||||
|
features = []
|
||||||
|
for block in blocks:
|
||||||
|
# Compute the mean and standard deviation of each color channel
|
||||||
|
mean_y, mean_cr, mean_cb = np.mean(block, axis=(0, 1))
|
||||||
|
std_y, std_cr, std_cb = np.std(block, axis=(0, 1))
|
||||||
|
features.extend([mean_y, mean_cr, mean_cb, std_y, std_cr, std_cb])
|
||||||
|
|
||||||
|
# Step 7: Concatenate features into a single vector
|
||||||
|
cld_vector = np.array(features)
|
||||||
|
|
||||||
|
return cld_vector
|
||||||
|
|
||||||
|
|
||||||
|
def color_layout_hello_world(image1_path, image2_path, block=8, resize_to_px=256):
|
||||||
|
"""
|
||||||
|
Compare two images using the Color Layout Descriptor.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
image1_path (str): Path to the first image
|
||||||
|
image2_path (str): Path to the second image
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: Similarity score between the two images
|
||||||
|
"""
|
||||||
|
image1 = cv2.imread(image1_path)
|
||||||
|
image2 = cv2.imread(image2_path)
|
||||||
|
|
||||||
|
cld1 = color_layout_descriptor(image1, block, resize_to_px)
|
||||||
|
cld2 = color_layout_descriptor(image2, block, resize_to_px)
|
||||||
|
|
||||||
|
# Compute the Euclidean distance between the two CLD vectors
|
||||||
|
distance = np.linalg.norm(cld1 - cld2)
|
||||||
|
|
||||||
|
# Convert the distance to a similarity score (lower values indicate higher similarity)
|
||||||
|
similarity = 1 / (1 + distance)
|
||||||
|
|
||||||
|
return similarity
|
||||||
|
|
||||||
|
|
||||||
|
input_jpg = "building.jpg"
|
||||||
|
building_jpg = "building/256.jpg"
|
||||||
|
|
||||||
|
similarity = color_layout_hello_world(input_jpg, building_jpg, 8, 256)
|
||||||
|
print(f"diff: {similarity:.4f} ({abs(1-similarity):.4f})")
|
@@ -0,0 +1,216 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0179 (0.9821)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0274 (0.9726)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0180 (0.0180)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0177 (0.9823)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0293 (0.9707)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0193 (0.0193)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0180 (0.9820)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0290 (0.9710)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0191 (0.0191)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0181 (0.9819)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0295 (0.9705)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0192 (0.0192)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0180 (0.9820)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0297 (0.9703)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0191 (0.0191)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 1 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0114 (0.9886)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0299 (0.9701)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0140 (0.0140)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0031 (0.9969)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0044 (0.9956)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0029 (0.0029)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 4 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0026 (0.9974)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0061 (0.9939)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0027 (0.0027)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0013 (0.9987)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0017 (0.9983)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0012 (0.0012)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 9 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0011 (0.9989)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0026 (0.9974)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0012 (0.0012)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0007 (0.9993)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0009 (0.9991)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0006 (0.0006)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 16 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0006 (0.9994)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0014 (0.9986)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0007 (0.0007)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0004 (0.9996)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0006 (0.9994)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0004 (0.0004)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 25 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0004 (0.9996)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0009 (0.9991)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0004 (0.0004)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 16
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 32
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 64
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 128
|
||||||
|
diff beach_1 loopback (expected same = 1) : nan (nan)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : nan (nan)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : nan (nan)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : nan (nan)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 256
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0003 (0.9997)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0004 (0.9996)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0003 (0.0003)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
using b: 36 r: 512
|
||||||
|
diff beach_1 loopback (expected same = 1) : 1.0000 (0.0000)
|
||||||
|
diff beach_1 beach_2 (expected similar ~ 1) : 0.0003 (0.9997)
|
||||||
|
diff beach_1 beach_138_jpg (expected same ~ 1) : 0.0006 (0.9994)
|
||||||
|
diff beach_1 bus_jpg (expected different ~ 0) : 0.0003 (0.0003)
|
File diff suppressed because it is too large
Load Diff
5
vinniesniper-54816/task1/_lab/015-helloworld/setup.sh
Normal file
5
vinniesniper-54816/task1/_lab/015-helloworld/setup.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
pip install opencv-python
|
18
vinniesniper-54816/task1/_lab/015-helloworld/test.py
Normal file
18
vinniesniper-54816/task1/_lab/015-helloworld/test.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os,sys
|
||||||
|
import cv2 as cv
|
||||||
|
|
||||||
|
c_img = cv.imread("beach.jpg")
|
||||||
|
bw_img = cv.imread("beach.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
|
|
||||||
|
print(c_img[100,100,0])
|
||||||
|
|
||||||
|
cv.imwrite("beach_done.jpg", bw_img);
|
||||||
|
# cv.imshow('windowname', img);
|
||||||
|
r_img=cv.resize(bw_img, (320, 240))
|
||||||
|
cv.imwrite("beach_resize.jpg", r_img);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print("done")
|
Reference in New Issue
Block a user