span8
span4
span8
span4
The RasterConvolver transformer is available in 2018.1+
An edge in a raster dataset is where the intensity of the values changes abruptly.Edges generally occur at the boundary of areas or objects, and so (for spatial data) are useful for extracting important features such as the edge of an area of vegetation.
Edges can be detected in FME with the RasterConvolver transformer, using a process called Convolution.
Convolutionis a mathematical operation carried out between a raster feature and a matrix of numbers (a kernel).The definition of operation and kernel is often called afilter.
The "direction" of an edge is from the low intensity part towards the high intensity part.Edges can occur in either a primarily vertical or horizontal orientation.Therefore the RasterConvolver allows the user to detect edges from left to right, right to left, top to bottom, or bottom to top.
Where the raster has a mix of edge directions, or where the primary edge direction is not known, it's possible to detect edges in all four directions, and to merge them together with an ExpressionEvaluator.This example uses that technique.
Starting Workspace as a Template
Completed Workspace as a Template
The source data for these examples is a Raster image dataset in JPEG format.In the FME Data Inspector it looks like this:
The image is an aerial view of an area of Vancouver containing a school.Let's say that for this exercise we wish to identify the different surfaces and buildings on the school grounds.
1.Start FME Workbench and open the starting template file provided.This workspace reads the image data and a rough outline of the school property, which it uses to clip the image to size:
Turn on feature caching in Workbench (Run > Run with Feature Caching) and run the workspace.Inspect the clipped result:
2.Add a RasterConvolver transformer connected to the Clipper:Inside port.Open the parameters dialog to inspect the different filter types.Notice that there are four edge detection filters called Sobel:
Select Sobel Top and click OK to close the parameters dialog.Run the workspace (or just this part of it) and inspect the output.Notice that edges are being detected.
However, there are three other Sobel edge detection filters, and we should also try these out.
3.Add three more RasterConvolver transformers.Connect each of them to a new connection from the Clipper:Inside port:
Sobel组每个人都使用不同的过滤器: Sobel Top, Sobel Bottom, Sobel Left, Sobel Right.
Run the workspace (select the RasterConvolver transformers and press F6).Inspect the output (select the RasterConvolver transformers and press Ctrl+I).
Notice that each type of filter adds information about edges viewed from a different direction.To get a complete result we should merge these together.
4.Place a RasterExpressionEvaluator transformer on the canvas and, without connecting to anything else, open up the parameters dialog.
Set the Mode parameter to Two Rasters:
In the Band Expression(s) field, set the first Interpretation to Red8.In the Expression field enter:
@sqrt((A[0]*A[0]) + (B[0]*B[0]))
In other words we are combining band zero of the two raster features together.The new value for each cell will be the square root of Raster A's value (squared) plus Raster B's value (squared).
Repeat the process for bands one and two (Green8 and Blue8), changing the band number in the expression each time:
@sqrt((A[1]*A[1]) + (B[1]*B[1])) @sqrt((A[2]*A[2]) + (B[2]*B[2]))
Now close the parameter dialog and connect the first two RasterConvolver outputs to the A and B input ports on the RasterExpressionEvaluator:
Notice that the RasterExpressionEvaluator does not allow all four rasters to be processed at once;therefore we need to use multiple transformers.
5.Duplicate the existing RasterExpressionEvaluator (either copy/paste or Ctrl+D).Connect it to the second set of RasterConvolver:Output ports.Because the expression is exactly the same the parameters do not need to be changed.
Now duplicate one of the RasterExpressionEvaluators for a second time.This time connect it to the Result ports of the existing RasterExpressionEvaluators:
Now run the workspace and inspect the result of the third RasterExpressionEvaluator:
We can see the edges of the surfaces and buildings, but there is a fair amount of noise in the image too.
6.Add a RasterConvolver transformer between the Clipper and each of the existing RasterConvolver transformers (for Quick Add click on the green output port arrow on the Clipper before typing the RasterConvolver name):
Open the parameters dialog and set the Convolution Filter type to Blur: Gaussian 5
Re-run the workspace and inspect the final output once more.Although the edges of the surfaces are a little fuzzier, there is far less noise in the image.
7.If you would prefer a white image with black outlines (instead of black with white outlines) then open the parameters dialog for the final RasterExpressionEvaluator.Change the expressions to:
255-(@sqrt((A[0]*A[0]) + (B[0]*B[0]))) 255-(@sqrt((A[1]*A[1]) + (B[1]*B[1]))) 255-(@sqrt((A[2]*A[2]) + (B[2]*B[2])))
For an 8-bit raster, 255 minus the value gives an inverted image.
You may also add a RasterInterpretationCoercer transformer to the end of the workspace to make the color a standard grey.Set the option for "Destination Interpretation Type" toGray8and the option for "Convert Color to Color" toCast.
Re-run the workspace.The final output will now be black lines on a white background:
You can now use these outlines (in either a manual or automated process) to determine the surfaces and buildings on the school property.
The quality of the results depends very much on the image having clear and well-defined boundaries, between areas that differ greatly in intensity.
For example here the user attempts to define the edges of containers sitting on a dock:
Unfortunately, the edges with the most intensity differences are the container shadows;therefore the shadows have the clearest edge definition while the containers are hidden against the background surface.
有很多方法,我认为你可以试试这个。作为使用RasterToPolygonCoercer变压器(也许有DonutHoleExtractor跟随)这可能是那样简单。还有使用Potrace其他解决方案(见https://knowledge.亚搏在线safe.com/articles/53522/raster-to-cad-using-potrace.html)了。的前体,这些方法是使用像RasterCellValueReplacer或RasterExpressionEvaluator变压器清理数据(例如,设置为0,其中所述单元格的值<128,或设置为255,其中它是> 128)。
我希望这有帮助。如果您对这些过程的问题,请他们在这里发表到论坛,我们(包括安全和FME社区)会很乐意帮忙。亚搏在线亚搏国际在线官网
Using Conditions with the RasterExpressionEvaluator Transformer
Alternative Mosaicking Method for Images with Fuzzy Edges
Handling CMYK color values in FME
Viewing and Inspecting Rasters
Raster Mask and LOD (Level of Detail) for KML Output
Working with Raster Readers for Satellite Imagery
Simple Examples Using the RasterExpressionEvaluator Transformer
How To Optimize Your Raster Data Using the RasterInterpretationCoercer
© 2019 Safe Software Inc |Legal