N ways to remove black edges from images

Insert image description here

In the process of image processing, sometimes it is necessary to mosaic several small images into one large one, but they are blocked by black edges. In this case, you need to find a way to remove the black edges. Since remote sensing images are generally too large to obtain and process, the image we choose here is a small image we have used before. Although it has white edges instead of black edges, the method is actually the same. , are all universal.

Please note here that N=7 pictures.

Insert image description here

1. Use symbology to remove

We right-click the image layer, select Properties->Symbolism->RGB Composition, check [Show background values ​​(B): (R, G, B)], and click Apply.

Insert image description here

However, this method only prevents the white edges from being displayed. It is not removed in the true sense. The white edges still exist in the image data set. If we do not process the images and only use them for visual interpretation, we can use this method. , but if you want to mosaic multiple images, you cannot use this method.

2. Custom removal

Before importing images, set ArcMap map properties. Click Customize→Select ArcMAP Options→Raster→Raster Layer-Remove Background Values ​​and check Show Background Values.

Insert image description here

However, removing black edges in this way is the same as using symbology to remove black edges. It only changes the display state of the background and does not make any changes to the data itself. When the layer is reloaded, black edges will still be displayed, but there are The good thing is that if there are multiple images, this method can unify them all without displaying black borders, and there is no need to use the symbology system to operate one by one.

3. Use tools to remove

Here are three tools that can remove black edges from images, one is the [Copy Raster] tool, the other is the [Raster Calculator] tool, and the other is the [Set to Empty Function] tool.

Tool location:

Data Management Tools->Raster->Raster Dataset->Copy Raster.

Spatial Analyst Tools->Map Algebra->Raster Calculator.

Spatial Analyst Tools->Conditional Analysis->Set to empty function.

  1. Copy Raster Tool

When using this tool, you need to know what the background value is. The white edge is generally 255, and the black edge is generally -999. To ensure correctness, you can use the identification tool to detect it.

Insert image description here
Insert image description here

Input the detection results into [NoData Value] and click Confirm. The processed image will no longer have black edges.

Insert image description here

However, the color of the image will become lighter after processing. If you don't care, you can choose not to use this method.

Insert image description here
Insert image description here

  1. Raster Processor Tool

When using this tool, you also need to know what the background value is, and enter the following formula in the raster processor:

SetNull("Gongzhuling City_Wei Map_Level_14.tif" == 255, "Gongzhuling City_Wei Map_Level_14.tif")

Insert image description here

If it is a black border, change 255 to -999. It depends on the background value.

A serious problem with this method is that when the processed raster dataset is loaded in, it turns gray as a whole, the symbology changes to stretched display, and there is no longer an option for RGB synthesis.

Insert image description here

The left side shows the symbology before processing, and the right side shows the symbology after processing.

Insert image description here
Insert image description here

Therefore, this method has greater limitations in use and can only be used when the image is not affected by this change. It is best to process single-band data.

  1. Set to empty function tool

The principle of this tool is the same as that of the raster processor, which is to set a certain value to Nodata (here we set the pixel with a value of 255 to Nodata. If it is a black border, change 255 to -999. The details still depend on the background. value, other pixel values ​​remain unchanged).

When the raster dataset processed by this tool is loaded in, it also turns gray as a whole, the symbology also changes to stretched display, and there is no longer an option for RGB synthesis.

Therefore, this tool can only operate on single-band data. If the data we get is single-band, then this method cannot be more suitable.

Insert image description here

Insert image description here

4. Removal of black edges caused by software incompatibility

If the image pyramids generated by two different software are also likely to have black edges, for example, if erdas is used to generate a pyramid with an edge of 0-value images, then the image will definitely have black edges when it is imported into arcgis for display. This situation is caused by the incompatibility between the two softwares. The solution is to delete all the original pyramids and use the arcgis pyramid tool to recreate all the pyramids, so that there will be no black edges.

Tool location: Data Management Tools->Raster->Raster Properties->Build Pyramid

Insert image description here

5. Use the image analysis window to remove

Click on the window and select Image Analysis.

Insert image description here

Select the image layer to be edited → click Add Function → right-click to identify the function in the new pop-up dialog box → select Insert → Select Mask Function.

Insert image description here
Insert image description here

The raster function properties window pops up, change the no data conversion to [All], the band has no data value, enter 0 to remove the black edges, and enter 255 for the white edges.

Insert image description here

After clicking OK in turn, the software will generate a new layer. This layer is where we have removed the black edges. It should be noted that this layer is only temporary data. After removal, it needs to be processed again before the effect can appear again. You need to export it to the computer to make it your own data, or you can choose to perform it directly on the processing result. Inlay and other operations.

Insert image description here

6. Remove black edges from mosaic data set

The mosaic dataset of ArcGIS is an ideal and practical image data management model. It is also a good choice for us to use it to "process" large amounts of raster data.

After ensuring quality in everything, when there is too much repetitive work, efficiency needs to be ensured at the same time, so this method is suitable for "a lot", "a large amount"...

Insert image description here

Insert image description here
Insert image description here

Create a mosaic dataset in the geodatabase, where the coordinate system can be added by importing, and the data is added to the mosaic dataset.

Insert image description here

After that, you can use the [Define Mosaic Dataset Nodata] tool in the mosaic dataset to define the invalid values ​​of the data. Select ALL_BANS for the NoData value band, set the NoData value to 255 (the value of the white edge previously detected with the identification tool), check [Synthesize NoData values ​​based on each band], the remote sensing image has 3 bands, after selecting only these three The pixel will become NoData only when the values ​​of each band are 255.

Tool location: Data Management Tools->Raster->Mosaic Dataset->Define Mosaic Dataset Nodata

Insert image description here

The mosaic dataset itself also supports raster functions. Similar to the function template settings in the image data window, function chains can also be set to implement some complex requirements.

7. Other methods

Is the black border of the image too stubborn? GIS can't be removed no matter what? !
The "magical" solution to the problem of dense small holes in images.
Summary of common Global Mapper techniques (common format conversion, image splicing, geometric correction...)

  • END -

Guess you like

Origin blog.csdn.net/qq_43173805/article/details/127432133