当前位置:网站首页>Gee: use of common mask functions in remote sensing image processing [updatemask]
Gee: use of common mask functions in remote sensing image processing [updatemask]
2022-07-02 05:11:00 【Gee water ecological space】
To learn, you must be rigid and constant , If it's not rigid, it's easy , If it doesn't last, it will fall back .—— The song dynasty . Fengzixian
Preface
GEE The mask correlation function in 3 individual , Respectively mask、updateMask and unmask, Need to differentiate and master 3 Usage of mask function
One 、mask() function
- ee.Image.mask()
Get or set the mask of the image . The output image retains the metadata and footprints of the input image . Pixels whose mask changes from zero to another value will be filled with zero , Or the value closest to zero in the range of pixel types .
Mask image . If specified , Then copy the input image to the output , But the mask is given by the value of the image . If this is a single band , Then it is used for all bands in the input image . If not specified , Returns the image created from the mask of the input image , Zoom to range 0:1.
Be careful : The version that sets the mask will be deprecated . To mask an image on a previously unmasked pixel , Please use Image.updateMask. To unshield previously masked pixels , Please use Image.unmask.
Usage method :image.mask(), Will use the mask area and non mask area of the image 0 and 1 Distinguish , among 1 Represented by mask ,0 Represents unmasked . Within the frame of the image , Black represents the masked area , White represents the unmasked area .
Two 、updateMask()
ee.Image.updateMask()
Update the mask of the image in all positions where the existing mask is not zero . The output image retains the metadata and footprints of the input image .
New mask for image , As 0, 1 Floating point values in range . If this image has a band , It is used to input all bands in the image ; otherwise , It must have the same number of bands as the input image .
Usage method :image.updateMask(),updateMask The image will be shown as 0 The area mask of , If you want one image to have the same mask as another , have access to image2.updateMask(image1.mask().not()).
3、 ... and 、unmask()
ee.Image.unmask()
In all positions where the input mask is zero , Replace the mask and value of the input image with the mask and value of another image . The output image retains the metadata of the input image . By default , The output image also retains the imported footsteps , But will sameFootprint Set to false Allow extended footsteps .
Usage method ,image.unmask(number),unmask Its function is that it can replace the image value of the masked area with any value , The unmasked area remains the original value . for example image.unmask(-9999) The value in the masked area will be replaced by -9999, In this way, the image can be compared with arcgis Seamless compatibility .
Four 、 Case practice
python The code is as follows :
(1) Image data
image = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
trueColor = {
'bands':['B4', 'B3', 'B2'],
'min':0, 'max':2800,
'gamma':1.5
}
# Load image
Map = geemap.Map()
Map.addLayer(image, trueColor, 's2 image')
Map.centerObject(image)
Map
(2) Corresponding mask processing
# ********** Replace all mask areas with a certain value , Use unmask**********
# # ********** Mask out unqualified pixels , Use updateMask**********
# utilize SWIR1 establish land Boolean band , among water by 0,land by 1
landMask = image.select('B11').gt(100)
# Apply mask band to update the original image , It will make the mask on the image equal to 0 All pixels of become invalid values
imageMasked = image.updateMask(landMask) # Only reserved land
# Load two images , landMask The image can be clearly divided into 2 Color ,0 For blue ,1 It's green
Map.addLayer(landMask, {'palette': ['blue', 'lightgreen']}, 'Land mask')
Map.addLayer(imageMasked, trueColor, 'imageMasked')
# ********** Replace all mask areas with a certain value , Use unmask**********
# Set invalid mask value , Replace the unmasked area with 32767 Null value appears
imageUnmasked = imageMasked.unmask(32767)
Map.addLayer(imageUnmasked, trueColor, 'image unmasked')
# Reset mask pixels to valid , Use the default value 0 fill , Enter footsteps
maskResetFootprint = imageMasked.unmask()
Map.addLayer(maskResetFootprint, trueColor, 'maskResetFootprint')
# Use something else 1 Image pixel value replacement
fill = ee.Image('COPERNICUS/S2_SR/20200618T184919_20200618T190341_T10SEG')
imgFill = imageMasked.unmask(fill)
Map.addLayer(fill, trueColor, 'new s2')
Map.addLayer(imgFill, trueColor, 'image filled')
The results are illustrated below :
5、 ... and 、 Summary
- GEE in 3 A common mask function ,mask, updateMask and unmask, among mask As a function about to be discarded , It is not recommended to use too much . It can be used flexibly updateMask and Mask Realize data processing and analysis .
- Using mask analysis , It can realize the magical function of transplanting flowers and trees , It is interesting to
Reference resources :
- https://developers.google.com/earth-engine/apidocs/ee-image-unmask?hl=en
- https://blog.csdn.net/SunStrongInChina/article/details/110388401
边栏推荐
- Global and Chinese market of hydrocyclone desander 2022-2028: Research Report on technology, participants, trends, market size and share
- C # picture display occupancy problem
- Lm09 Fisher inverse transform inversion mesh strategy
- Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
- Fabric.js 将本地图像上传到画布背景
- About PROFIBUS: communication backbone network of production plant
- Video cover image setting, put cover images into multiple videos in the simplest way
- Fasttext text text classification
- [opencv] image binarization
- Mysql重点难题(2)汇总
猜你喜欢
Fabric.js IText 上标和下标
06 decorator mode
Lay the foundation for children's programming to become a basic discipline
The underlying principle of go map (storage and capacity expansion)
About PROFIBUS: communication backbone network of production plant
10 minute quick start UI automation ----- puppeter
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel
Getting started with pytest ----- confitest Application of PY
Black Horse Notes - - set Series Collection
Preparation for writing SAP ui5 applications using typescript
随机推荐
el form 表单validate成功后没有执行逻辑
C case of communication between server and client based on mqttnet
农业生态领域智能机器人的应用
Draw a wave chart_ Digital IC
Mathematical knowledge (Euler function)
Mysql基础---查询(1天学会mysql基础)
Future trend of automated testing ----- self healing technology
Fabric.js IText设置指定文字的颜色和背景色
fastText文本分类
Oracle和MySQL的基本区别(入门级)
Getting started with pytest -- description of fixture parameters
Mysql重点难题(2)汇总
Fabric.js 圆形笔刷
Ansible installation and use
List of common bugs in software testing
Johnson–Lindenstrauss Lemma(2)
Go GC garbage collection notes (three color mark)
Record my pytorch installation process and errors
Mathematical knowledge -- understanding and examples of fast power
C# 图片显示占用问题