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

Support for imresize on color images #563

Closed
wants to merge 2 commits into from

Conversation

fpreiswerk
Copy link

@fpreiswerk fpreiswerk commented Oct 10, 2016

My humble attempt to make imresize work on color images.

For an RGB image, b=imresize(a,(new_x, new_y)) does the same as b=imresize(a,(new_x, new_y, 3)). However, if the size of the output color dimension is different from the size of the input color dimension, an error is thrown. For example, the following does not work for the above example: b=imresize(a,(new_x, new_y, 2))

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 78.703% when pulling ae993a7 on fpreiswerk:master into d20aa18 on timholy:master.

@timholy
Copy link
Member

timholy commented Oct 17, 2016

Sorry I didn't notice this---I've been pretty preoccupied with #542. I really appreciate this!

One of the things I noted is that this does already work if you represent a color image using a Color type:

julia> using Images, Colors

julia> img = rand(RGB{U8}, 10, 8);

julia> Images.imresize(img, (13, 11))
13×11 Array{ColorTypes.RGB{FixedPointNumbers.UFixed{UInt8,8}},2}:
 RGB{U8}(0.137,0.757,0.133)  RGB{U8}(0.463,0.643,0.227)    RGB{U8}(0.569,0.827,0.482)  RGB{U8}(0.082,0.694,0.6)  
 RGB{U8}(0.314,0.365,0.451)  RGB{U8}(0.263,0.298,0.561)     RGB{U8}(0.655,0.51,0.553)   RGB{U8}(0.286,0.502,0.886)
 RGB{U8}(0.416,0.125,0.608)  RGB{U8}(0.431,0.11,0.761)      RGB{U8}(0.733,0.373,0.592)  RGB{U8}(0.659,0.494,0.686)
 RGB{U8}(0.573,0.22,0.529)   RGB{U8}(0.592,0.243,0.69)      RGB{U8}(0.749,0.286,0.541)  RGB{U8}(0.89,0.424,0.439) 
 RGB{U8}(0.918,0.827,0.141)  RGB{U8}(0.361,0.871,0.2)       RGB{U8}(0.635,0.129,0.341)  RGB{U8}(0.659,0.031,0.584)
 RGB{U8}(0.835,0.855,0.675)  RGB{U8}(0.78,0.827,0.302)     RGB{U8}(0.573,0.58,0.647)   RGB{U8}(0.855,0.494,0.275)
 RGB{U8}(0.522,0.796,0.443)  RGB{U8}(0.8,0.624,0.239)       RGB{U8}(0.667,0.549,0.502)  RGB{U8}(0.859,0.675,0.486)
 RGB{U8}(0.404,0.671,0.259)  RGB{U8}(0.737,0.522,0.173)     RGB{U8}(0.745,0.408,0.29)   RGB{U8}(0.733,0.592,0.82) 
 RGB{U8}(0.918,0.51,0.941)   RGB{U8}(0.929,0.788,0.282)     RGB{U8}(0.631,0.525,0.408)  RGB{U8}(0.533,0.263,0.871)
 RGB{U8}(0.965,0.247,0.467)  RGB{U8}(0.863,0.435,0.145)     RGB{U8}(0.427,0.545,0.486)  RGB{U8}(0.373,0.161,0.294)
 RGB{U8}(0.91,0.549,0.22)    RGB{U8}(0.722,0.341,0.161)    RGB{U8}(0.545,0.337,0.537)  RGB{U8}(0.525,0.259,0.376)
 RGB{U8}(0.69,0.89,0.141)    RGB{U8}(0.533,0.38,0.263)      RGB{U8}(0.714,0.239,0.435)  RGB{U8}(0.573,0.341,0.494)
 RGB{U8}(0.239,0.753,0.196)  RGB{U8}(0.322,0.42,0.384)      RGB{U8}(0.659,0.576,0.051)  RGB{U8}(0.094,0.18,0.016) 

In the future, most algorithms that want to treat color-as-color will use a Color type, and in the new images there are good tools for "virtually" interpreting even an m×n×3 arrays as if it's an m×n RGB array: http://juliaimages.github.io/latest/. (That documentation is for the future version of Images, not the current one.)

@fpreiswerk
Copy link
Author

I understand. Using RGB arrays clearly seems more Julian. That new documentation looks encouraging already. Looking forward to the next version, thank you for all the work.

@timholy timholy closed this in 03c2c8c Feb 4, 2017
timholy added a commit that referenced this pull request Feb 4, 2017
Test imresize with color images. Fixes #563.
@timholy
Copy link
Member

timholy commented Feb 4, 2017

Obviated by the new Images, see also #585.

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

Successfully merging this pull request may close these issues.

None yet

3 participants