SciTech-Math-AdvancedAlgebra-Linear Spaces(Vector Spaces) and Subspace: The Column Space of a Matrix

Resources:

N-element ordered Number Sequence
Sets: K^n, Operations:{ScalarMultiplication, Addition, Other8rules}
Vector: N-Dimensional vector
Relationship between Vectors:

  • Linear Combinations
  • Linear Representation
  • Linear
    Linear Spaces(Vector Spaces) are Sets
    Linear Combinations
import cv2 as cv

img_garden = cv.imread("/Users/abaelhe/Desktop/TheGarden.png")
img_emily = cv.imread("/Users/abaelhe/Desktop/EmilyDickinson.png")
math_merged = (
  ratio*img_garden + (1.0-ratio)* img_emily
).astype(np.uint8)

img_garden_gray = cv.cvtColor(img_garden, cv.COLOR_RGB2GRAY)
img_emily_gray = cv.cvtColor(img_emily, cv.COLOR_RGB2GRAY)
math_merged_gray = (
  ratio*img_garden_gray + (1.0-ratio)* img_emily_gray
).astype(np.uint8)

def merge_flatten_img(
  background, front,
  bg_ratio=0.4, filter_ratio=0.3):
    front_mean = front.mean()
    front_min = int(front_mean*(1-filter_ratio))
    front_max = int(front_mean*(1+filter_ratio))
    ret = []
    for (bg, ft) in zip(background, front):
        if (front_min <= ft <= front_max):
            ret.append( int(bg_ratio*bg + (1-bg_ratio)*ft) )
        else:
            ret.append( ft )
    return np.array(ret, dtype=np.uint8)

math_filter_gray = merge_flatten_img(
  img_garden_gray.flatten(), img_emily_gray.flatten()
).reshape(img_emily.shape[:-1])

im_r = merge_flatten_img(
  img_garden[:,:,0].flatten(), img_emily[:,:,0].flatten()
)
im_g = merge_flatten_img(
  img_garden[:,:,1].flatten(), img_emily[:,:,1].flatten()
)
im_b = merge_flatten_img(
  img_garden[:,:,2].flatten(), img_emily[:,:,2].flatten()
)
im_zip = tuple(zip(im_r.tolist(), im_g.tolist(), im_b.tolist()))
math_filter_color = np.array(
  im_zip, dtype=np.uint8
).flatten().reshape(img_emily.shape)

imgshow(math_merged, save_to='/Users/abaelhe/Desktop/math_merged.png')
imgshow(math_merged_gray, save_to='/Users/abaelhe/Desktop/math_merged_gray.png')
imgshow(math_filter_gray, save_to='/Users/abaelhe/Desktop/filter_gray.png')
imgshow(math_filter_color, save_to='/Users/abaelhe/Desktop/filter_color.png')
#TheGarden: #EmilyDickinson:
#math_merged: #filter_color:
#math_merged_gray: #filter_gray:
posted @ 2024-01-18 10:15  abaelhe  阅读(10)  评论(0)    收藏  举报