Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature suggest: include an example which eventually runs by fpm run #1

Open
nbehrnd opened this issue Jul 19, 2023 · 4 comments
Open
Assignees

Comments

@nbehrnd
Copy link
Contributor

nbehrnd commented Jul 19, 2023

Based on the information the landing page provides, I attempted to install forimage. By the information collected so far (see log attached below), the fpm-based installation did not include the section [dependencies] yet. Is --perfix a flag added just recently to the fpm?

Second -- partly because the ford-based documentation still is under construction -- I would like to suggest to extend the set up. While forimage aims to be a library to contribute in other projects, can an fpm-based installation be modified in a way that a call by fpm run executes a small test application? This is inspired by the «first steps» appetizing section of the fpm tutorial here.

2023-07-19_forimage.log

@gha3mi gha3mi self-assigned this Jul 20, 2023
gha3mi added a commit that referenced this issue Jul 20, 2023
@gha3mi
Copy link
Owner

gha3mi commented Jul 20, 2023

Thanks @nbehrnd.

I have updated the README and fpm.toml files. There was a mistake in the README. It must be "prefix" not "perfix."

As you mentioned, forimage is a library, not a program. Therefore, I didn't create a main program. However, the examples are in the example directory and can be run using fpm as follows:

fpm run --example --all
fpm run --example example1

Or using response files for specific compilers:

fpm @example-ifort
fpm @example-ifx
fpm @example-gfortran
fpm @example-nvfortran

Please note that these changes haven't been merged with the main branch yet. They are in the branch: https://github.com/gha3mi/forimage/tree/gha3mi/issue1.

Could you please review these updates?

gha3mi added a commit that referenced this issue Jul 20, 2023
@nbehrnd
Copy link
Contributor Author

nbehrnd commented Jul 25, 2023

@gha3mi I just run the instructions on an instance Linux Debian 13/trixie for an explicit checkout of the branch addressing the issue. fpm seems to have lesser problems.

As for running the examples: it is bit difficult to recognize if they were changed. I assumed the time stamps by ls -l could be an option to discern original and processed file; but it does not look like. Manual inspection of folder pnm_files displays them; here my initial thought was example1.pbm is about the original, and example1_ex.pbm the processed after passing file I/O. Hélas, ls -l does not help, nor the inspection with imagemagick's display. The difference mentioned by md5sum is -- as by vimdiff -- to complete the alter the line example to example 1 for the first example.

I perceive this as a small change only; leaning on the side of «too small». (And if request display to open example1.pbm and example3.ppm, they are tiny in dimension -- example example2.pgm is much easier to manage.) It would be considerably more attractive if changes would become visible already by a simultaneous display of original file in vs processed file out without of intervention of a text editor.

2023-07-25_forimage.log.txt

@gha3mi
Copy link
Owner

gha3mi commented Jul 25, 2023

Thanks, @nbehrnd, for testing the examples. I'm glad to see that the code can successfully generate, read (import) and write (export) pnm files.


The examples demonstrate how to set up a pnm file, save it, import it, and save it again. For instance, in example 3, you can set some data for a ppm file using the following procedure:

call ex3%set_pnm(encoding='plain', file_format='ppm', width=4, height=4, max_color=15, comment='example 2', pixels=px)

Then, the code saves it to a file using the export procedure:

call ex3%export_pnm('pnm_files/example3')

Afterward, it is possible to import the file back into the program:

call ex3%import_pnm('pnm_files/example3', 'ppm', 'plain')

At this point, some processing can be done, although it's not provided in these examples. Finally, after any possible processing, the code exports it again using:

call ex3%export_pnm('pnm_files/example3_ex')

  • If you can't find any difference between the generated and exported files, it's good news, as it indicates that the import and export procedures are functioning correctly.

  • You mentioned a known bug in the comment part of the header of PNM files, which I also noticed. Also, the import procedure reads only the first word of the comment after the # symbol. (We should open a new issue to solve this minor bug.)

  • As an idea, we could consider implementing a procedure to compare two files in Fortran. Something like this:

call compare_pnm('pnm_files/example3', 'pnm_files/example3_ex', 'ppm', 'plain')

In this case, the compare_pnm subroutine could compare the header data of the two files first, and if they are the same, it could proceed to check the pixels and finally show the compared results.


  • The test examples 1 to 3 are simple and small. If you have some idea and time to generate other (bigger) examples, you could implement them as new examples and send a pull request (PR). I use GIMP instead of ImageMagick to view the files, and I've attached the output of examples 1 to 3 in GIMP.

example1
example2
example3


  • Regarding image processing ideas, I am thinking of using low-rank approximation with SVD, which is implemented here. While I am not an expert in image processing, if you have some ideas to implement some image processing examples, it could be interesting. (here we could open a new issue to do it.)

@nbehrnd
Copy link
Contributor Author

nbehrnd commented Aug 2, 2023

By now, the intended working is better understood (cf. log of a pristine session). Test/check files: a topic for a bit later.

2023-08-02_forimage.log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants