Skip to content

Commit

Permalink
version 2018-02-18 alpha
Browse files Browse the repository at this point in the history
- improve error handling to limit cascades and to simplify embedding in
other programs
- update doc
- update copyright
- add man placeholder
  • Loading branch information
retokromer committed Feb 18, 2018
1 parent a811c8d commit 6684ed9
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 434 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ Joakim Reuteler and Rudolf Gschwind ([Digital Humanities Lab](http://dhlab.uniba

An alpha of a [modified code](lenticular/README.md) is available for testing purpose. And contributions are very welcome!

### Licence and Disclaimer
### Copyright, Licence and Disclaimer

This work is released under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) Licence.
Copyright (c) 2012 Joakim Reuteler
Copyright (c) 2018 AMIA Open Source

The program is released under a [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) Licence and the documentation is released under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) Licence.

This work is provided «as is» without warranty or support of any kind.
28 changes: 14 additions & 14 deletions lenticular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Thank you!
- I was told that a logo would be important.
- Understand and document the parameters.
- Upload test files on GitHub. Who can provide some for public usage?
- Fix error handling. In particolar avoid the `Segmentation fault: 11` message, most probably due to wrongly set arrays’ indices.
- Allow full path for both the input and the output folder. In particular, the output folder has not to be nested inside the input folder, but can be chosen freely, e.g. on another hard-disk drive.
- Allow to choose the name of the output files.
- Add flags for mandatory parameters and allow free input order.
Expand All @@ -34,8 +35,8 @@ Thank you!

### Long-term goals

- **CLI:** A command-line program that can be used by other softwares as well. That way, for example, FFmpeg (`ffmpeg` and `ffplay`) or `mpv` could be compiled with, or the restoration software `Diamant` could use it as a plug-in. The capability to use a library as a filter on the media player allows to show on-the-fly the lenticular colours while reading a greyscale file.
- **GUI:** A stand-alone program – directly inspired by [AEO-Light](https://usc-imi.github.io/aeo-light/) – that allows to generate the colours of digitised lenticular movie films, like _Kodacolor_ and _Agfacolor_. This allows to tune the parameters for a better result.
- **CLI:** A command-line program that can be used by other software as well. That way, for example, FFmpeg (`ffmpeg` and `ffplay`) or `mpv` could be compiled with, or the restoration software `Diamant` could use it as a plug-in. The capability to use a library as a filter on the media player allows to show on-the-fly the lenticular colours while reading a greyscale file. This may be useull for quickly check if a film has been shot with the RGB filter on the lens or not.
- **GUI:** A stand-alone program – directly inspired by [AEO-Light](https://usc-imi.github.io/aeo-light/) – that allows to generate the colours of a digitised lenticular movie films, like _Kodacolor_ and _Agfacolor_. This allows to tune the parameters for a better result.

---

Expand Down Expand Up @@ -77,7 +78,7 @@ Brew installation and `doLCE` have been successfully tested on the following ope
### Parameters

```
modified doLCE 2018-02-16 alpha
modified doLCE 2018-02-18 alpha
doLCE [-help] [-highRes] [-profileRelThickness (float)]
[-profileRelPosY (float)] [-relaxRaster]
Expand All @@ -101,6 +102,7 @@ Please note that, like in the original code, as well as in the current version:
- the output folder must be nested inside the input folder
- only the name of the output folder must be entered (with the path from the input folder on, if any, but not the full path)
- in the example above the last output file is `~/TEST/SOURCE_FILES/NEW_FILES/rgb_greyscale_0057.tif`
- inconsistent input may provoke a `Segmentation fault: 11` error

#### Optional parameters

Expand All @@ -116,8 +118,8 @@ Please note that, like in the original code, as well as in the current version:

The original source code comes with the following two additional tools:

- `inStudy`: interpolation study on `rgb48le`
- `frameCropper`: frame cropper
- `inStudy`: pixel column interpolation study on `rgb48le`
- `frameCropper`: crop center part of RGB frames

Note that we just have started to explore the additional tools.

Expand All @@ -140,18 +142,17 @@ inStudy
which should give:

```
modified inStudy 2018-02-16 alpha
modified inStudy 2018-02-18 alpha
RGB image pixel column interpolation study
ERROR: Too few arguments.
inStudy [--help] 'inputFileName'
```

Note that:

- the «option '--help' [is] ignored at the moment», as is any passed flag;
- **inputFileName:** currently the input file must be at the same level than `inStudy`. Hmm…
- when only a flag is passed, a `Segmentation fault: 11` occurs

#### Frame cropper

Expand All @@ -171,20 +172,19 @@ which should give:


```
modified frameCropper 2018-02-16 alpha
modified frameCropper 2018-02-18 alpha
crop center part of RGB frames
ERROR: Too few arguments.
frameCropper 'width' 'height' 'inputBaseName' 'startNo' 'endNo' 'outputDir'
```

---

## Licence and Disclaimer
## Copyright, Licence and Disclaimer

The current maintainer is [Reto Kromer](https://github.com/retokromer).
Copyright (c) 2012 Joakim Reuteler
Copyright (c) 2018 AMIA Open Source

This work is released under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) Licence.
The program is released under a [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) Licence and the documentation is released under a [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) Licence.

This work is provided «as is» without warranty or support of any kind.
25 changes: 12 additions & 13 deletions lenticular/frameCropper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* frameCropper.c
* - crop center part of RGB frames
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down Expand Up @@ -34,7 +34,7 @@ int main( int argc, char *argv[] ) {

// constants
char greetingText[128] = "";
sprintf( greetingText, "\nmodified frameCropper 2018-02-16 alpha\n crop center part of RGB frames\n\n" );
sprintf( greetingText, "\nmodified frameCropper 2018-02-18 alpha\n crop center part of RGB frames\n\n" );
char helpText[] = "frameCropper 'width' 'height' 'inputBaseName' 'startNo' 'endNo' 'outputDir'\n\n";
char inputImageName[128] = "";
char inputBaseName[128] = "";
Expand All @@ -43,7 +43,7 @@ int main( int argc, char *argv[] ) {
char endNoStr[16] = "";
int endNo;
char outputDirName[128] = "";
char outputImageName[132] = "";
char outputImageName[128] = "";
int frameNo;
char frameNoFormat[8] = "";
char frameNoStr[16] = "";
Expand All @@ -64,9 +64,12 @@ int main( int argc, char *argv[] ) {
outImg.memState = 0;

printf( "%s", greetingText );
if ( argc < 7 ) {
status = -1;
if ( argc < 2 ) {
printf( "%s", helpText );
exit(0);
} else if ( argc < 7 ) {
printf( "ERROR: Too few arguments.\n\n%s", helpText );
exit(1);
} else {
argNo = 1;
printf( "argNo = %d\n", argNo );
Expand All @@ -81,27 +84,23 @@ int main( int argc, char *argv[] ) {
strcpy( outputDirName, argv[++argNo] );
printf( "image sequence to be processed: '%s%s.tif' to '%s%s.tif'\n", inputBaseName, startNoStr, inputBaseName, endNoStr );
printf( "cropped frames will be stored as '%s/crp_%s%s.tif' etc.\n", outputDirName, inputBaseName, startNoStr );
}
if ( status == 0 ) {
printf( "\nlog of call: '" );
printf( "\nCOMMAND: " );
for ( argNo = 0 ; argNo < argc; argNo++ )
printf( "%s ", argv[argNo] );
printf( "'\n" );
printf( "\n" );
if ( strlen(startNoStr) == strlen(endNoStr) ) {
if ( strlen(startNoStr) == 1 )
sprintf( frameNoFormat, "%%d" );
else
sprintf( frameNoFormat, "%%0%dd", (int)strlen(startNoStr) );
} else {
if ( strlen(startNoStr) > 1 && startNoStr[0] == 0 ) {
status = -1;
printf( "ERROR: Cannot handle this kind of numbering:\n" );
printf( " startNoStr[0] == 0\n" );
printf( " startNoStr == %s\n", startNoStr );
exit(1);
}
}
}
if ( status == 0 ) {
printf( "\n-------------------loop over frames----------------------\n\n" );
for ( frameNo = startNo; frameNo <= endNo && status == 0; frameNo++ ) {
sprintf( frameNoStr, frameNoFormat, frameNo );
Expand Down
16 changes: 8 additions & 8 deletions lenticular/imageHandling.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* - memory handling for grey-level and RGB images
* - read and write TIFF images
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down Expand Up @@ -492,15 +492,15 @@ int write_3x8bitTIFF_rgbImage( rgbImage_t *rgbImage, char *toTIFFname ) {
TIFFSetField( outTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
if ( (lineBuffer = malloc( 3*width*sizeof(unsigned char) )) == NULL ) {
status = -1;
printf ( "ERROR : write_3x8bitTIFF_rgbImage(): failed to allocate memory for 'lineBuffer'.\n" );
printf ( "ERROR: write_3x8bitTIFF_rgbImage(): failed to allocate memory for 'lineBuffer'.\n" );
}
for ( j=0; j < height && status == 0; j++ ) {
for ( i=0; i < width; i++ )
for ( c=0; c<3; c++ )
lineBuffer[3 * i + c] = (unsigned char)(rgbImage->img[c][j][i]);
if (TIFFWriteScanline (outTIFF, lineBuffer, j, 0) == -1) {
status = -1;
printf ( "ERROR : write_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
printf ( "ERROR: write_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
}
}
free( lineBuffer );
Expand Down Expand Up @@ -549,15 +549,15 @@ int writeROI_3x8bitTIFF_rgbImage( rgbImage_t *rgbImage, char *toTIFFname, int ro
TIFFSetField( outTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
if ( (lineBuffer = malloc( 3*width*sizeof(unsigned char) )) == NULL ) {
status = -1;
printf ( "ERROR : writeROI_3x8bitTIFF_rgbImage(): failed to allocate memory for line buffer.\n" );
printf ( "ERROR: writeROI_3x8bitTIFF_rgbImage(): failed to allocate memory for line buffer.\n" );
}
for ( j=0; j < roiHeight && status == 0; j++ ) {
for ( i=0; i < roiWidth; i++ )
for ( c=0; c<3; c++ )
lineBuffer[3*i+c] = (unsigned char)(rgbImage->img[c][j + roiYpos][i + roiXpos]);
if (TIFFWriteScanline (outTIFF, lineBuffer, j, 0) == -1) {
status = -1;
printf ( "ERROR : writeROI_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
printf ( "ERROR: writeROI_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
}
}
free( lineBuffer );
Expand Down Expand Up @@ -601,15 +601,15 @@ int write_3x16bitTIFF_rgbImage( rgbImage_t *rgbImage, char *toTIFFname ) {
TIFFSetField( outTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
if ( (lineBuffer = malloc( (long)(rgbImage->width) * 3 * sizeof(uint16) )) == NULL ) {
status = -1;
printf ( "ERROR : write_3x16bitTIFF_rgbImage(): failed to allocate memory for 'lineBuffer'.\n" );
printf ( "ERROR: write_3x16bitTIFF_rgbImage(): failed to allocate memory for 'lineBuffer'.\n" );
}
for ( j=0; j < height && status == 0; j++ ) {
for ( i=0; i < width; i++ )
for ( c=0; c<3; c++ )
lineBuffer[3*i+c] = (uint16)(rgbImage->img[c][j][i]);
if (TIFFWriteScanline (outTIFF, lineBuffer, j, 0) == -1) {
status = -1;
printf ( "ERROR : write_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
printf ( "ERROR: write_3x8bitTIFF_rgbImage(): failed to write scan line (%d).\n", j );
}
}
free( lineBuffer );
Expand Down
8 changes: 4 additions & 4 deletions lenticular/imageHandling.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/******************************************************************************
*
* imageHandling.h
* - define structures to hold grey-level and RGB images
* - memory handling
* - declare structures to hold both grey-level and RGB images
* - read and write TIFF images
* - memory handling
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down
4 changes: 2 additions & 2 deletions lenticular/imageProcessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* imageProcessing.c
* - simple operations on images
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down
4 changes: 2 additions & 2 deletions lenticular/imageProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* imageProcessing.h
* - declare simple operations on images
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down
16 changes: 7 additions & 9 deletions lenticular/interpolationStudy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* interpolationStudy.c
* - RGB image pixel column interpolation study
*
* this is part of:
* This file is part of doLCE (do Lenticular film Color rEconstruction).
*
* doLCE (do Lenticular film Color rEconstruction)
* Copyright (c) 2012 Joakim Reuteler
* Copyright (c) 2018 AMIA Open Source
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
Expand Down Expand Up @@ -34,7 +34,7 @@ int main( int argc, char *argv[] ) {

// constants
char greetingText[128] = "";
sprintf( greetingText, "\nmodified inStudy 2018-02-16 alpha\n RGB image pixel column interpolation study\n\n" );
sprintf( greetingText, "\nmodified inStudy 2018-02-18 alpha\n RGB image pixel column interpolation study\n\n" );
char helpText[] = "inStudy [--help] 'inputFileName'\n\n";
char inputImageName[128] = "";
char outputImageName[128] = "";
Expand All @@ -52,8 +52,8 @@ int main( int argc, char *argv[] ) {

printf( "%s", greetingText );
if ( argc < 2 ) {
status = -1;
printf( "ERROR: Too few arguments.\n\n%s", helpText );
printf( "%s", helpText );
exit(0);
} else {
optNo = 0;
argNo = 1;
Expand All @@ -65,13 +65,11 @@ int main( int argc, char *argv[] ) {
argNo++;
}
if ( optNo + 1 != argc - 1 )
printf( "WARNING: Several input images specified, only first one will be read at the moment.\n" );
strcat( inputImageName, argv[optNo+1] );
printf( "WARNING: Several input images specified, only first one will be read at the\n moment.\n" );
strcat( inputImageName, argv[optNo + 1] );
printf( "image to load: %s\n", inputImageName );
sprintf( outputImageName, "study_%s", inputImageName );
printf( "result will be written to '%s'\n", outputImageName );
}
if ( status == 0 ) {
printf( "Checking input image...\n" );
status = check_TIFF( inputImageName, &spp, &bps, &width, &height );
if ( status == 0 ) {
Expand Down
25 changes: 25 additions & 0 deletions lenticular/lenticular.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.TH "lenticular" "1" "https://github\.com/amiaopensource/lenticular" "2018\-02\-18" "AMIA Open Source"
.SH NAME
\fBlenticular \fR\- Digital restoration of lenticular colours from greyscale digitisations
.SH SYNOPSIS
.
.SS
\fBdoLCE
to do
.
.SS
\fBframeCropper
to do
.
.SS
\fBinStudy
to do
.
.SH COPYRIGHT
Copyright (c) 2012 Joakim Reuteler
.LP
Copyright (c) 2018 AMIA Open Source
.SH LICENSE
The program is released under a GNU General Public License version 3 and the documentation is released under a Creative Commons Attribution 4\.0 International License\.
.SH DISCLAIMER
The lenticular package is provided "as is" without warranty or support of any kind\.
Loading

0 comments on commit 6684ed9

Please sign in to comment.