Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 improved formatting
source | link

Mathematica, 86 84 bytes

Thanks to DavidC for the advice. (saves 2 bytes)

Export[#2,⌊Mean@Join[#,(r=Reverse)/@#]&@{#,r/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images, respectively.

Test cases:


Test cases

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result

Result: (pngPNG versions of the images isare uploaded here.below)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here

Mathematica, 86 84 bytes

Thanks to DavidC for the advice. (saves 2 bytes)

Export[#2,⌊Mean@Join[#,(r=Reverse)/@#]&@{#,r/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images respectively.

Test cases:

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result: (png versions of the images is uploaded here.)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here

Mathematica, 86 84 bytes

Thanks to DavidC for the advice. (saves 2 bytes)

Export[#2,⌊Mean@Join[#,(r=Reverse)/@#]&@{#,r/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images, respectively.


Test cases

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result

(PNG versions of the images are uploaded below)

Import["penguin2.pnm"]

Import["quintopia2.pnm"]

Import["peter2.pnm"]

2 added 70 characters in body
source | link

Mathematica, 8686 84 bytes

Thanks to DavidC for the advice. (saves 2 bytes)

Export[#2,⌊Mean@Join[#,Reverse(r=Reverse)/@#]&@{#,Reverser/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images respectively.

Test cases:

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result: (png versions of the images is uploaded here.)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here

Mathematica, 86 bytes

Export[#2,⌊Mean@Join[#,Reverse/@#]&@{#,Reverse/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images respectively.

Test cases:

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result: (png versions of the images is uploaded here.)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here

Mathematica, 86 84 bytes

Thanks to DavidC for the advice. (saves 2 bytes)

Export[#2,⌊Mean@Join[#,(r=Reverse)/@#]&@{#,r/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images respectively.

Test cases:

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result: (png versions of the images is uploaded here.)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here

1
source | link

Mathematica, 86 bytes

Export[#2,⌊Mean@Join[#,Reverse/@#]&@{#,Reverse/@#}&@Import[#,"Data"]⌋~Image~"Byte"]&

The first and second parameters are the paths to the input and output images respectively.

Test cases:

f=%; (assign the function to symbol f)
f["penguin.pnm","penguin2.pnm"]
f["quintopia.pnm","quintopia2.pnm"]
f["peter.pnm","peter2.pnm"]

Result: (png versions of the images is uploaded here.)

Import["penguin2.pnm"]

enter image description here

Import["quintopia2.pnm"]

enter image description here

Import["peter2.pnm"]

enter image description here