1

I have 35 large sized .ecw images that I need to change to greyscale and then export as .tiff for someone else to use in AutoCAD.

In QGIS I can display the images in greyscale and then Save As and choose the 'rendered' option.

Is there a way that I can do this as a batch? My images are 500-700Mb each and can take an hour each to save. I'd like a way to do this as a batch process.

Any suggestions?

4
  • Use gdal_translate.
    – user30184
    Oct 4 '17 at 4:39
  • Can you be more specific so that this answer is more instructive?
    – Johanna
    Oct 4 '17 at 4:55
  • Read gdal.org/gdal_translate.html and if there is something that is not clear edit your question to be more specific.
    – user30184
    Oct 4 '17 at 8:34
  • You must also define what do you mean with "change to greyscale". How would you construct the greyscale: by picking just one band from the ecw or perhaps by taking them all and computing the average, or maybe a somehow weighted average?
    – user30184
    Oct 4 '17 at 9:02
1

I have found a workaround.

My plan had been to convert the .ecw files to .tiff and then use XnConvert to .jpg. I have discovered that there are other versions of my .ecw files that are already in .tiff format so I am able to use XnConvert to change them to greyscale and save as .jpg in one process.

0

Forgive me for butting in, but let me give it a try.

Given I have GeoTiffs in C:\GIS\Tiff_folder.

  1. Create new folder to store output files (e.g. "C:\GIS\MyOutputs")
  2. Start OSGeo4W Shell
  3. Type cd "C:\GIS\Tiff_folder" to move to the input folder.
  4. Type for %f in (*.tif) do gdal_translate -of GTiff -ot Byte -scale 100 500 1 255 -co BIGTIFF=IF_NEEDED "%f" C:/GIS/MyOutputs/%f

If successful, your converted grey images will appear in newly created MyOutputs folder, with the same filename as original GeoTiffs.

[EDIT] I have just realized you have .ecw files... so it has to be like below, and you might have to adjust filenames afterwords:

  1. Type for %f in (*.ecw) do gdal_translate -of GTiff -ot Byte -scale 100 500 1 255 -co BIGTIFF=IF_NEEDED "%f" C:/GIS/MyOutputs/%f.tif

Please change -scale 100 500 1 255 according to your input file. (My example case was DEMs within 100m-500m). As commented by user30184, it is probably difficult part of this task... how best you can define the greyscale range.

2
  • In QGIS, I have used the Layer Properties dialogue box to set the Color Rendering to Grayscale 'By Average'. Then, I can right click the image, choose Save As and set the Output Mode to Rendered Image to save as a greyscale [my Australian spelling] .tiff Each image takes over half an hour to save. I was hoping to find a way to process the 35 images as a batch.
    – Johanna
    Oct 4 '17 at 21:31
  • G'Day @Johanna, I understood you need to include color rendering as a part of the batch process, to which I do not have answer. (and sorry I do not know what is By Average method). As you might have to continue working one-by-one on your dataset while waiting for solutions, I would suggest stop displaying [1] your layers, by ticking-off on the Layers Panel; and [2] saved raster, by not to add saved file to map. It may help lessen a burden.
    – Kazuhito
    Oct 4 '17 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.