±à¼ÍƼö: |
±¾ÎÄÀ´×ÔÓÚ51cto,ÎÄÕÂÖ÷Òª½éÉÜÈçºÎµ¼ÈëͼÏñ²¢¹Û²ìÆäÊôÐÔ¡¢²ð·Öͼ²ãÒÔ¼°²é¿´»Ò¶È£¬Ï£Íû¶Ô´ó¼ÒµÄѧϰÄÜÓÐËù°ïÖú¡£ |
|
±¾½Ì³Ì½«½éÉÜÈçºÎµ¼ÈëͼÏñ²¢¹Û²ìÆäÊôÐÔ¡¢²ð·Öͼ²ãÒÔ¼°²é¿´»Ò¶È¡£ÔÚÕýʽ¿ªÊ¼Ö®Ç°£¬ÎÒÃÇÏÈÀ´Á˽âһЩ¹ØÓÚÏñËØµÄ»ù´¡ÖªÊ¶¡£
¼ÆËã»ú½«Í¼Æ¬ÒÔÏñËØÐÎʽ´æ´¢£¬Õâ¾ÍÏñÂíÈü¿ËÒ»Ñù¡£Èç¹ûÏñËØÌ«´ó£¬ºÜÄÑÖÆ×÷¹â»¬µÄ±ßÔµºÍÇúÏß¡£Ïà·´£¬ÎÒÃÇʹÓõÄÏñËØÔ½¶àԽС£¬¿´ÆðÀ´¾Í»áԽƽ»¬£¬»òÕß˵ÏñËØ»¯³Ì¶ÈԽС£¬Í¼Ïñ¾Í»áÔ½ºÃ¿´£¬ÓÐʱ£¬ÕâÒ²±»³ÆÎªÍ¼Ïñ·Ö±æÂÊ¡£

ʸÁ¿Í¼ÐÎÊÇÒ»ÖÖÓе㲻ͬµÄ´æ´¢Í¼Ïñ·½·¨£¬Ö¼ÔÚ±ÜÃâÓëÏñËØÏà¹ØµÄÎÊÌâ¡£µ«ÊÇ£¬¼´Ê¹ÊÇʸÁ¿Í¼Ïñ£¬×îÖÕÒ²»áÏÔʾΪÏñËØÒ»ÑùµÄÂíÈü¿Ë¡£ÑÕÉ«ÏñËØ±íʾͼÏñÔªËØ£¬ÃèÊöÿ¸öÏñËØµÄ¼òµ¥·½·¨ÊÇʹÓÃÈýÖÖÑÕÉ«µÄ×éºÏ£¬¼´ºìÉ«£¬ÂÌÉ«£¬À¶É«£¬Õâ¾ÍÊÇÎÒÃÇËù˵µÄRGBͼÏñ¡£
ÔÚRGBͼÏñÖУ¬Ã¿¸öÏñËØ·Ö±ðÓëºìÉ«£¬ÂÌÉ«£¬À¶É«µÄÖµÏà¹ØÁªµÄÈý¸ö8±ÈÌØÊý×Ö±íʾ¡£×îºó£¬Èç¹ûʹÓ÷Ŵ󾵹۲ìËõ·ÅµÄͼƬ£¬ÎÒÃǻῴµ½Í¼Æ¬ÓÉ΢СµÄ¹âµã»ò¸ü¾ßÌåµÄÏñËØ×é³É£¬¸üÓÐȤµÄÊÇÕâЩС¹âµãʵ¼ÊÉϾßÓжà¸ö²»Í¬ÑÕÉ«¡£
ÿÕÅÕÕÆ¬¶¼ÒÔÊý×ÖÐÎʽÓÉÏñËØ×é³É£¬ËüÃÇÊǹ¹³ÉͼƬµÄ×îСÐÅÏ¢µ¥Î»£¬Í¨³£ÊÇÔ²Ðλò·½ÐΣ¬ËüÃÇͨ³£²¼ÖÃÔÚ¶þÎ¬Íø¸ñÖС£

Èç¹ûÈý¸öÑÕÉ«¶¼´¦ÓÚ×î´óÖµ£¬ÔòÒâζ×ÅËüÃÇÊÇ255£¬ÄǾͻáÏÔʾΪ°×É«£¬Èç¹ûÈýÖÖÑÕÉ«¶¼´¦ÓÚ×îСֵ£¬»òÕßֵΪ0£¬ÔòÑÕÉ«ÏÔʾΪºÚÉ«¡£·´¹ýÀ´£¬ÕâÈýÕßµÄ×éºÏ½«ÎªÎÒÃÇÌá¹©ÌØ¶¨µÄÏñËØÑÕÉ«¡£ÓÉÓÚÿ¸öÑÕÉ«Êý×Ö¶¼ÊÇ8¸ö±ÈÌØ£¬Òò´ËÖµ·¶Î§Îª0-255¡£

ÓÉÓÚÿ¸öÖµ¿ÉÒÔ¾ßÓÐ256¸ö²»Í¬µÄÇ¿¶È»òÁÁ¶ÈÖµ£¬Òò´ËÈýÖÖÑÕÉ«×ܹ²ÓÐ1680Íò¸öshade¡£

ÒÔÏÂÊÇNumpyand·Ç³£»ù±¾µÄͼÏñÊý¾Ý·ÖÎö²½Ö裬ÆäÖÐÒ»Ð©Éæ¼°Python pacakges£¬Èçimageio£¬matplotlibµÈ¡£
µ¼ÈëͼÏñ²¢¹Û²ìÆäÊôÐÔ
²ð·Öͼ²ã
Greyscale
¶ÔÏñËØÖµÊ¹ÓÃÂß¼ÔËËã·û
ʹÓÃÂß¼ÔËËã·û½øÐÐÔËËã
ÎÀÐÇͼÏñÊý¾Ý·ÖÎö
µ¼ÈëͼÏñ
ÏÖÔÚÈÃÎÒÃǼÓÔØÍ¼Ïñ²¢¹Û²ì¸÷ÖÖÊôÐÔ£º
if __name__
== '__main__':
import imageio
import matplotlib.pyplot as plt
%matplotlib inline
pic = imageio.imread('F:/demo_2.jpg')
plt.figure(figsize = (15,15))
plt.imshow(pic)¹Û²ìͼÏñµÄ»ù±¾ÊôÐÔ
print('Type of the image : ' , type(pic))
print('Shape of the image : {}'.format(pic.shape))
print('Image Hight {}'.format(pic.shape[0]))
print('Image Width {}'.format(pic.shape[1]))
print('Dimension of Image {}'.format(pic.ndim))
Type of the image :
Shape of the image : (562, 960, 3)
Image Hight 562
Image Width 960
Dimension of Image 3 |

ndarrayµÄÐÎ×´±íÃ÷ËüÊÇÒ»¸öÈý²ã¾ØÕó£¬ÕâÀïµÄǰÁ½¸öÊý×ÖÊdz¤¶ÈºÍ¿í¶È£¬µÚÈý¸öÊý×Ö(¼´3)ÊÇÈý²ã£ºRed,
Green, Blue¡£ Òò´Ë£¬Èç¹ûÎÒÃǼÆËãRGBͼÏñµÄ´óС£¬Ôò×Ü´óС½«¼ÆÎªheight x width
x 3
print('Image
size {}'.format(pic.size))
print('Maximum RGB value in this image {}'.format(pic.max()))
print('Minimum RGB value in this image {}'.format(pic.min()))
Image size 1618560
Maximum RGB value in this image 255
Minimum RGB value in this image 0 |
ÕâЩֵ¶ÔÓÚÑéÖ¤ºÜÖØÒª£¬ÒòΪ8±ÈÌØÑÕɫǿ¶È²»Äܳ¬³ö0µ½255·¶Î§¡£
ÏÖÔÚ£¬Ê¹ÓÃͼƬ·ÖÅä±äÁ¿£¬ÎÒÃÇ»¹¿ÉÒÔ·ÃÎÊͼƬµÄÈκÎÌØ¶¨ÏñËØÖµ£¬²¢½øÒ»²½·ÃÎÊÿ¸öRGBͨµÀ¡£
'''
Let's pick a specific pixel located at 100 th
Rows and 50 th Column.
And view the RGB value gradually.
'''
pic[ 100, 50 ]
Image([109, 143, 46], dtype=uint8) |
ÔÚÕâÖÖÇé¿öÏ£ºR = 109; G = 143; B = 46£¬ÎÒÃÇ¿ÉÒÔÒâʶµ½Õâ¸öÌØÊâÏñËØÖÐÓкܶàÂÌÉ«¡£ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔͨ¹ý¸ø³öÈý¸öͨµÀµÄË÷ÒýÖµÀ´ÌرðÑ¡ÔñÆäÖÐÒ»¸öÊý×Ö£º
0ºìɫͨµÀµÄË÷ÒýÖµ
1ÂÌɫͨµÀµÄË÷ÒýÖµ
2À¶É«Í¨µÀµÄË÷ÒýÖµ
µ«ÊÇ£¬ÔÚOpenCVÖУ¬Í¼Ïñ²»ÊÇRGB¶øÊÇBGR£¬imageio.imread½«Í¼Ïñ¼ÓÔØÎªRGB(»òRGBA)£¬µ«OpenCV¼Ù¶¨Í¼ÏñΪBGR»òBGRA(BGRÊÇĬÈϵÄOpenCVÑÕÉ«¸ñʽ)¡£
# A specific
pixel located at Row : 100 ; Column : 50
# Each channel's value of it, gradually R , G
, B
print('Value of only R channel {}'.format(pic[
100, 50, 0]))
print('Value of only G channel {}'.format(pic[
100, 50, 1]))
print('Value of only B channel {}'.format(pic[
100, 50, 2]))
Value of only R channel 109
Value of only G channel 143
Value of only B channel 46 |
ºÃµÄ£¬ÏÖÔÚÈÃÎÒÃÇ¿ìËٲ鿴Õû¸öͼÏñÖеÄÿ¸öƵµÀ¡£
plt.title('R
channel')
plt.ylabel('Height {}'.format(pic.shape[0]))
plt.xlabel('Width {}'.format(pic.shape[1]))
plt.imshow(pic[ : , : , 0])
plt.show() |

plt.title('G
channel')
plt.ylabel('Height {}'.format(pic.shape[0]))
plt.xlabel('Width {}'.format(pic.shape[1]))
plt.imshow(pic[ : , : , 1])
plt.show() |

plt.title('B
channel')
plt.ylabel('Height {}'.format(pic.shape[0]))
plt.xlabel('Width {}'.format(pic.shape[1]))
plt.imshow(pic[ : , : , 2])
plt.show() |

ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔ¸ü¸ÄRGBÖµµÄÊýÁ¿¡£ÀýÈ磬ÈÃÎÒÃǶԺìÉ«¡¢ÂÌÉ«¡¢À¶É«Í¼²ãÉèÖøúËæÐÐÖµµÄÇ¿¶È¡£
RƵµÀ£ºÐÐ - 100µ½110
GƵµÀ£ºÐÐ - 200µ½210
BƵµÀ£ºÐÐ - 300µ½310
ÎÒÃǽ«¼ÓÔØÒ»´ÎͼÏñ£¬ÒÔ±ã¿ÉÒÔͬʱÏÔʾÿ¸ö²ãµÄ±ä»¯¡£
pic = imageio.imread('F:/demo_2.jpg')
pic[50:150 , : , 0] = 255 # full intensity to
those pixel's R channel
plt.figure( figsize = (10,10))
plt.imshow(pic)
plt.show() |

pic[200:300
, : , 1] = 255 # full intensity to those pixel's
G channel
plt.figure( figsize = (10,10))
plt.imshow(pic)
plt.show() |

pic[350:450
, : , 2] = 255 # full intensity to those pixel's
B channel
plt.figure( figsize = (10,10))
plt.imshow(pic)
plt.show() |

ΪÁ˸üÇå³þ£¬ÈÃÎÒÃÇÒ²¸Ä±äÁв¿·Ö£¬Õâ´ÎÎÒÃǽ«Í¬Ê±¸ü¸ÄRGBͨµÀ¡£
# set value
200 of all channels to those pixels which turns
them to white
pic[ 50:450 , 400:600 , [0,1,2] ] = 200
plt.figure( figsize = (10,10))
plt.imshow(pic)
plt.show() |

²ð·Öͼ²ã
ÏÖÔÚ£¬ÎÒÃÇÖªµÀͼÏñµÄÿ¸öÏñËØ¶¼ÓÉÈý¸öÕûÊý±íʾ£¬½«Í¼Ïñ·Ö¸î³Éµ¥¶ÀµÄÑÕÉ«·ÖƬֻÐèÀ³öͼÏñÕóÁеÄÕýÈ·ÇÐÆ¬¡£
import numpy
as np
pic = imageio.imread('F:/demo_2.jpg')
fig, ax = plt.subplots(nrows = 1, ncols=3, figsize=(15,5))
for c, ax in zip(range(3), ax):
# create zero matrix
split_img = np.zeros(pic.shape, dtype="uint8")
# 'dtype' by default: 'numpy.float64'
# assing each channel
split_img[ :, :, c] = pic[ :, :, c]
# display each channel
ax.imshow(split_img) |

»Ò¶È
ºÚ°×ͼÏñ´æ´¢ÔÚ¶þάÕóÁÐÖУ¬ÓÐÁ½ÖÖÀàÐ͵ĺڰ×ͼÏñ£º
Greyscale£º»ÒÉ«ÒõÓ°·¶Î§£º0~255
Binary£ºÏñËØÎªºÚÉ«»ò°×É«£º0»ò255
ÏÖÔÚ£¬GreyscalingÊÇÒ»¸ö½«Í¼Ïñ´Óȫɫת»»Îª»ÒÉ«ÒõÓ°µÄ¹ý³Ì¡£ÔÚͼÏñ´¦Àí¹¤¾ßÖУ¬ÀýÈ磺ÔÚOpenCVÖУ¬Ðí¶à¹¦ÄÜÔÚ´¦Àí֮ǰʹÓûҶÈͼÏñ£¬ÕâÑù×öÊÇÒòΪËü¼ò»¯ÁËͼÏñ£¬¼¸ºõ¿ÉÒÔ½µÔë²¢Ôö¼Ó´¦Àíʱ¼ä£¬ÒòΪͼÏñÖеÄÐÅÏ¢½ÏÉÙ¡£
ÔÚpythonÖÐÓÐÁ½ÖÖ·½·¨¿ÉÒÔ½«Í¼Ïñת»»Îª»Ò¶È£¬µ«Ê¹ÓÃmatplotlibµÄ¼òµ¥·½·¨ÊÇʹÓô˹«Ê½»ñÈ¡ÔʼͼÏñµÄRGBÖµµÄ¼ÓȨƽ¾ùÖµ¡£
Y' = 0.299 R
+ 0.587 G + 0.114 B
pic = imageio.imread('F:/demo_2.jpg')
gray = lambda rgb : np.dot(rgb[... , :3] , [0.299
, 0.587, 0.114])
gray = gray(pic)
plt.figure( figsize = (10,10))
plt.imshow(gray, cmap = plt.get_cmap(name = 'gray'))
plt.show() |

È»¶ø£¬GIMP½«ÑÕɫת»»Îª»Ò¶ÈͼÏñÈí¼þÓÐÈýÖÖËã·¨À´Íê³ÉÈÎÎñ¡£
»Ò¶ÈµÄLightness µÈ¼¶¼ÆËãΪ
Lightness =
? ¡Á (max(R,G,B) + min(R,G,B)) |
»Ò¶ÈµÄLuminosity µÈ¼¶¼ÆËãΪ
Luminosity =
0.21 ¡Á R + 0.72 ¡Á G + 0.07 ¡Á B |
»Ò¶ÈµÄAverage ¼ÆËãΪ
Average Brightness
= (R + G + B) ¡Â 3 |
ÈÃÎÒÃdz¢ÊÔÒ»ÏÂËã·¨£¬LuminosityЧ¹ûÈçºÎ?
pic = imageio.imread('F:/demo_2.jpg')
gray = lambda rgb : np.dot(rgb[... , :3] , [0.21
, 0.72, 0.07])
gray = gray(pic)
plt.figure( figsize = (10,10))
plt.imshow(gray, cmap = plt.get_cmap(name = 'gray'))
plt.show()
'''
Let's take a quick overview some the changed properties
now the color image.
Like we observe some properties of color image,
same statements are applying
now for gray scaled image.
'''
print('Type of the image : ' , type(gray))
print()
print('Shape of the image : {}'.format(gray.shape))
print('Image Hight {}'.format(gray.shape[0]))
print('Image Width {}'.format(gray.shape[1]))
print('Dimension of Image {}'.format(gray.ndim))
print()
print('Image size {}'.format(gray.size))
print('Maximum RGB value in this image {}'.format(gray.max()))
print('Minimum RGB value in this image {}'.format(gray.min()))
print('Random indexes [X,Y] : {}'.format(gray[100,
50]))
Type of the image :
Shape of the image : (562,960)
Image Height 562
Image Widht 960
Dimension of Image 2
Image size 539520
Maximum RGB value in this image 254.9999999997
Minimum RGB value in this image 0.0
Random indexes [X,Y] : 129.07 |
ʹÓÃÂß¼ÔËËã·û´¦ÀíÏñËØÖµ
ÎÒÃÇ¿ÉÒÔʹÓÃÂß¼ÔËËã·û´´½¨Ïàͬ´óСµÄbullion ndarray¡£µ«ÊÇ£¬Õâ²»»á´´½¨ÈκÎÐÂÊý×飬ËüÖ»Êǽ«Öµ·µ»Øµ½ÆäÖ÷±äÁ¿¡£ÀýÈ磬Èç¹û¿¼ÂÇÔÚRGBͼÏñÖÐÂ˳ýһЩµÍÖµÏñËØ»ò¸ßÖµ»ò(ÈκÎÌõ¼þ)£¬¿ÉÒÔÏȽ«RGBת»»Îª»Ò¶È¡£
Ê×ÏȼÓÔØÍ¼Ïñ²¢ÔÚÆÁÄ»ÉÏÏÔʾ£º
pic = imageio.imread('F:/demo_1.jpg')
plt.figure(figsize = (10,10))
plt.imshow(pic)
plt.show() |

½ÓÏÂÀ´£¬ÎÒÃÇ¿¼ÂÇת´¢¸ÃͼÏñ£¬±ÈÈçÎÒÃÇÏëÒª¹ýÂËËùÓеÍÓÚ20 µÄÏñËØÖµ¡£Îª´Ë£¬ÎÒÃǽ«Ê¹ÓÃÂß¼ÔËËã·ûÖ´ÐдËÈÎÎñ£¬·µ»ØËùÓÐË÷ÒýµÄTrueÖµ¡£
low_pixel =
pic < 20
# to ensure of it let's check if all values in
low_pixel are True or not
if low_pixel.any() == True:
print(low_pixel.shape)
(1079, 1293, 3) |
ÕýÈçÉÏÎÄËù˵£¬´«Í³Éϲ»Ê¹ÓÃËÞÖ÷±äÁ¿£¬µ«ÎÒÖ®ËùÒÔÌáµ½ÊÇÒòΪËüÖ»±£ÁôTrueÖµ¡£ ËùÒÔ£¬Èç¹ûÎÒÃÇ¿´µ½low_pixelºÍpicµÄ
shape£¬ÎÒÃǻᷢÏÖËüÃǶ¼¾ßÓÐÏàͬµÄ shape¡£
print(pic.shape)
print(low_pixel.shape)
(1079, 1293, 3)
(1079, 1293, 3) |
ÎÒÃÇʹÓÃÈ«¾Ö±È½ÏÔËËã·ûΪËùÓÐСÓÚ200µÄÖµÉú³ÉµÍÖµÂ˲¨Æ÷¡£µ«ÊÇ£¬ÎÒÃÇ¿ÉÒÔʹÓôËlow_pixelÊý×é×÷ΪË÷Òý½«ÕâЩµÍÖµÉèÖÃÎªÄ³Ð©ÌØ¶¨Öµ£¬ÕâЩֵ¿ÉÄܸßÓÚ»òµÍÓÚÏÈǰµÄÏñËØÖµ¡£
# randomly choose
a value
import random
# load the orginal image
pic = imageio.imread('F:/demo_1.jpg')
# set value randomly range from 25 to 225 - these
value also randomly choosen
pic[low_pixel] = random.randint(25,225)
# display the image
plt.figure( figsize = (10,10))
plt.imshow(pic)
plt.show() |

ͼ²ãÃɰæ
ͼÏñÃɰæÊÇÒ»ÖÖͼÏñ´¦Àí¼¼Êõ£¬ÓÃÓÚÈ¥³ý¾ßÓÐÄ£ºý±ßÔµ£¬Í¸Ã÷»òÍ··¢²¿·ÖµÄÕÕÆ¬±³¾°¡£
ÏÖÔÚ£¬ÎÒÃǽ«´´½¨Ò»¸öÔ²ÅÌÐÎ×´µÄÃɰ档Ê×ÏÈ£¬ÎÒÃǽ«²âÁ¿´ÓͼÏñÖÐÐĵ½Ã¿¸ö±ß½çÏñËØÖµµÄ¾àÀë¡£ÎÒÃÇÉèÖÃÒ»¸ö±È½Ï·½±ãµÄ°ë¾¶Öµ£¬È»ºóʹÓÃÂß¼ÔËËã·û´´½¨Ò»¸öÔ²ÅÌ£¬ÒÔÏÂΪ´úÂ룺
if __name__
== '__main__':
# load the image
pic = imageio.imread('F:/demo_1.jpg')
# seperate the row and column values
total_row , total_col , layers = pic.shape
'''
Create vector.
Ogrid is a compact method of creating a multidimensional-
ndarray operations in single lines.
for ex:
>>> ogrid[0:5,0:5]
output: [array([[0],
[1],
[2],
[3],
[4]]),
array([[0, 1, 2, 3, 4]])]
'''
x , y = np.ogrid[:total_row , :total_col]
# get the center values of the image
cen_x , cen_y = total_row/2 , total_col/2
'''
Measure distance value from center to each border
pixel.
To make it easy, we can think it's like, we draw
a line from center-
to each edge pixel value --> s**2 = (Y-y)**2
+ (X-x)**2
'''
distance_from_the_center = np.sqrt((x-cen_x)**2
+ (y-cen_y)**2)
# Select convenient radius value
radius = (total_row/2)
# Using logical operator '>'
'''
logical operator to do this task which will return
as a value
of True for all the index according to the given
condition
'''
circular_pic = distance_from_the_center > radius
'''
let assign value zero for all pixel value that
outside the cirular disc.
All the pixel value outside the circular disc,
will be black now.
'''
pic[circular_pic] = 0
plt.figure(figsize = (10,10))
plt.imshow(pic)
plt.show() |

ÎÀÐÇͼÏñ´¦Àí
ÎÀÐÇͼÏñ¼°Æä´¦Àíϵͳ·Ç³£ÓÐÓã¬ÎÒÃÇ¿ÉÒÔÓÃÓÚ×öһЩ·ÖÎöÈÎÎñ¡£
# load the image
pic = imageio.imread('F:\satimg.jpg')
plt.figure(figsize = (10,10))
plt.imshow(pic)
plt.show() |

ÎÒÃÇÀ´¿´Ò»Ð©»ù±¾ÐÅÏ¢£º
print(f'Shape
of the image {pic.shape}')
print(f'hieght {pic.shape[0]} pixels')
print(f'width {pic.shape[1]} pixels')
Shape of the image (3725, 4797, 3)
hieght 3725 pixels
width 4797 pixels |
ÕâÕÅͼƬÉÏÓÐһЩÓÐȤµÄ¶«Î÷£¬ÏñÐí¶àÆäËûµÄͼÏñ¿ÉÊÓ»¯Ò»Ñù£¬Ã¿¸öRGB²ãÖеÄÑÕÉ«¶¼ÓÐ×Ô¼ºµÄÒâ˼¡£ÀýÈ磬ºìÉ«µÄÇ¿¶È½«±íʾÏñËØÖеĵØÀíÊý¾ÝµãµÄ¸ß¶È£¬À¶É«µÄÇ¿¶È±íʾ·½Î»µÄ¶ÈÁ¿£¬ÂÌÉ«±íʾбÂÊ¡£ÕâЩÑÕÉ«½«ÓÐÖúÓÚÒÔ¸ü¿ì£¬¸üÓÐЧµÄ·½Ê½´«´ï´ËÐÅÏ¢£¬¶ø²»ÊÇÏÔʾÊý×Ö¡£
ºìÉ«ÏñËØ±íʾ£ºAltitude¡¤
À¶É«ÏñËØ±íʾ£ºAspect
ÂÌÉ«ÏñËØ±íʾ£º Slope
ͨ¹ý¹Û²ì²ÊɫͼÏñ£¬ÎÒÃÇ¿ÉÒÔ·Ö±æ³öº£°ÎÊǶàÉÙ£¬Ð±ÂÊÊǶàÉÙ£¬ÒÔ¼°SlopeÊÇʲô£¬Õâ¾ÍÊÇΪÑÕÉ«¼ÓÔØ¸ü¶àº¬ÒåÒÔ±íʾ¸ü¿ÆÑ§µÄ·ÖÎöµÄÏë·¨¡£
¼ì²âÿ¸öͨµÀµÄÏñËØ
# Only Red Pixel
value , higher than 180
pic = imageio.imread('F:\satimg.jpg')
red_mask = pic[:, :, 0] < 180
pic[red_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(pic)
# Only Green Pixel value , higher than 180
pic = imageio.imread('F:\satimg.jpg')
green_mask = pic[:, :, 1] < 180
pic[green_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(pic)
# Only Blue Pixel value , higher than 180
pic = imageio.imread('F:\satimg.jpg')
blue_mask = pic[:, :, 2] < 180
pic[blue_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(pic)
# Composite mask using logical_and
pic = imageio.imread('F:\satimg.jpg')
final_mask = np.logical_and(red_mask, green_mask,
blue_mask)
pic[final_mask] = 40
plt.figure(figsize=(15,15))
plt.imshow(pic) |

|