Skip to main content
I have images (3584 x 1792 pixels) and I'd like to set the RGB-values to zero for all lowest 300 rows of the images.

 

 

I've tried this with a RasterCreator (to create a white band of 300 x 3584) and a RasterMosaicker, this works fine. But only one of my input images is being masked.

 

 

Is there another way to do this?

 

Maybe with the PythonCaller? But I don't know how to loop through the pixels, and change their RGB-values.

 

 

J.

 

 

 

 

 

 

 
Hi,

 

 

unfortunately, it isn't possible to access pixel values using fmeobjects :-(

 

 

You'll have to use regular transformers.

 

 

David
Can I do this with regular transformers in a way all my input images will be changed?
Hi,

 

 

Yes, you can.

 

Assuming the sizes of source rasters are identical (3584 x 1792 pixels), create copies of the mask raster for each source rasters, and mosaic each pair (group) of source and mask.

 

I think "fme_basename" of the source is suitable to use as grouping attribute.

 

For example:

 

 

In addition, I would extend the data flow to guarantee to make the mosaicking order become proper and also improve performance:

 

(1) Add "_order" attribute; set "1" to every source, set "2" to every masks.

 

(2) Insert a Sorter immediately before the RasterMosaicker.

 

fme_basename  |  Alphabetic  |  Ascending

 

 _order  |  Numeric  |  Ascending

 

(3) Set "Yes" to the "Input is Ordered by Group" parameter of the RasterMosaicker.

 

 

Hope this helps.

 

 

Takashi
Hi,

 

 

The resolution of my rasters are identical indeed. But the amount of input rasters fluctuates from project to project (from 50 to 250). As fme_basename will fluctuate too from project to project, I don't see a way to create a set of n mask rasters

 

 

J.
Hi,

 

You can use a directory and filepath reader to read the inputfiles and a statistics calculator with the "total count attirubte" selected to get the number of rasters.

 

Summary output will give u a single value wich you can link to the mask raster using a 1 on 1 featuremerger (supplierattribute = 1 and requestor attribute =1). Then you can use this value to clone your rasters using a cloner.

 

 

If you have to filter the files based on a filename u can link the "Path Filter" (a parameter (green) in the navigator panel under the directory and filepath reader wich is named to the path you chose).

 

You can link this to a scripted parameter. In this scripted parameter you can use regular expressions to filter the files.
Thanks Gio and Takashi!
Any idea for this problem:

 

 

I want to add a white strip at the bottom of my images so that the width x hight ratio becomes 2:1.

 

 

e.g. image  5044 x 2134 --> add white strip so that imae is 5044 x 2522

 

 

But this time the size of my input images is not fixed.

 

 

J.

 

 

 
Hi again,

 

Different ways to do it.

 

One easy way is to use a rasterresampler set to like 0.1 percent (depends on the input resolution) This gives (if you have percentage small enough) a single colour raster of the same size, it will have a single coloured band.

 

Now use a scaler to scale it to x= 1 and y = width/2

 

 

Change color to white. You can change the color to white by using a rasteexpressionevaluator use relevant intepretation and enter "255".Then you will need to add the 2 other bands as well. Also "255" both.

 

 

 

Now you u can process it further to combine them.

 

using clipper, mosaicker, rastercombiner (though for this one you need to sync columns/rows) the rasters.

 

 

 
You can still use the RasterMosaicker.

 

 

Create offset white raster.

 

(1) Extract extent (xmin, ymin, xmax, ymax) of the original raster using the RasterPropertyExtractor.

 

(2) After calculating width and height based on the extent, use the Offsetter to move the raster by "-width / 2 + height" (i.e. the height of required strip) in y-direction.

 

(3) Use the RasterCellValueReplacer to assign white value to every cell of the offset raster.

 

 

And then, mosaic the offset raster and the original raster.

 

Just be aware that the offset raster should be sent to the RasterMosaicker before the original raster.
HI

 

 

Here is a pic of a solution.

 

This time by just colouring and scaling original. (no down to single pixel reduction like in my previous post)

 

(i used a jpg without alpha, so i added alpha band).

 

 

 

Holding feature is essential.

 

 


Thanks again Gio and Takashi

Reply