apply_to_image: Apply the improved Fuzzy Cluster Method (FCMm) to raster data

Description Usage Arguments Value Note References See Also Examples

View source: R/Image_application.R

Description

This function could apply the defined water cluster to corrected image files. Should run generate_param or generate_param_ex to generate a res list as an input of function apply_to_image

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
apply_to_image(
  input,
  res,
  color_palette = RdYlBu(res$K),
  pos_rgb = NULL,
  output_image = FALSE,
  output_resultpng = FALSE,
  output_imRrs.n = FALSE,
  output_dir = ".",
  output_format = "GTiff",
  Chla_est = FALSE,
  title.name = NULL,
  png_scale = 50,
  fn_memb = "output_membership",
  fn_cluster = "output_cluster",
  fn_imRrs.n = "output_imRrs_normalized",
  fn_rgbpng = "output_rgb",
  fn_Chla = "output_Chla"
)

Arguments

input

A raster or a character linking to the raster file on the disk.

res

A required list that used for clustering the image data including:

  • FD The results from function FuzzifierDetermination providing wavelength

  • K Cluster number

  • res.FCM Cluster center and used fuzzifier value.

For the convenience, function generate_param supports to quickly generate this list. See more in examples.

color_palette

The palette of cluster color. Default as RdYlBu(res$K). In FCMm, it could be RdYlBu, Spectral, HUE or other color values with same length of cluster number.

pos_rgb

The position of RGB channels, default as NULL to search the nearest band with 665 (n), 560 (g), and 443 (b). Also could be a vector with three elements meaning the positions of required bands.

output_image

Logical, whether to save images as raster files to your disk. Default as FALSE.

output_resultpng

Logical, whether to save png files to your disk. Default as FALSE.

output_imRrs.n

Logical, whether to produce normalized Rrs files. Default as FALSE. This parameter is used for inspection of FCM training. Will be deprecated in the following version.

output_dir

The directory of output files. Default as the current working directory (".")

output_format

A string, the format of raster file, default as "GTiff". See more in writeRaster

Chla_est

Logical, whether to estimate Chla concentration using the function FCM_m_Chla_estimation. Default as FALSE.

title.name

Character, the title name of ggplot for plotting. Default as NULL.

png_scale

Numeric, scale of png. Recommended as 50.

fn_memb

A string, filename of membership raster file. Default as "output_membership".

fn_cluster

A string, filename of cluster raster file. Default as "output_cluster".

fn_imRrs.n

A string, filename of normalized Rrs raster file. Default as "output_imRrs_normalized".

fn_rgbpng

A string, file name of rgb png. Default as "output_rgb".

fn_Chla

A string, file name of estimated Chla raster file. Default as "output_Chla".

Value

A list() of all results and several inputs:

Note

2019-12-12:

The section FCM running used the subset of default Rrs clusters. Please see the section Part II: New coming raster data by running vignette('Builtin_centrodis') if have not known how to do in that situation.

Also, if it is your first time to get the image data into R, you could load the raster data by typing raster::brick(filename) which filename is the path of your data such as '/data/Test.dat' or 'E://data//Test.tiff' or so.

2020-06-27:

Note that the inputs of apply_to_image support the file path of raster file.

2020-07-03:

Reported by Xiaolan Cai, the required RGB bands for plotting the true color image are defined by inputted wavelength now.

References

Bi S, Li Y, Xu J, et al. Optical classification of inland waters based on an improved Fuzzy C-Means method[J]. Optics Express, 2019, 27(24): 34838-34856.

See Also

Other Fuzzy cluster functions: FCM.new(), FuzzifierDetermination(), apply_FCM_m(), cal_memb(), generate_param(), plot_spec_from_df()

Examples

1
2
3
4
5
6
7
library(FCMm)
data("OLCI_TH")
data("Bi_clusters")
res <- generate_param(c(413,443,490,510,560,620,665,674,709,754,865,885))
im_result <- apply_to_image(input=OLCI_TH, res=res, title.name="Test_image", Chla_est=TRUE)

  

bishun945/FCMm documentation built on Oct. 15, 2021, 6:43 p.m.