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

Fix image channel convertion #226

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ end
local function todepth(img, depth)
if depth and depth == 1 then
if img:nDimension() == 2 then
-- all good
img = img:view(1, img:size(1), img:size(2))
elseif img:size(1) == 3 or img:size(1) == 4 then
img = image.rgb2y(img:narrow(1,1,3))[1]
img = image.rgb2y(img:narrow(1,1,3))
elseif img:size(1) == 2 then
img = img:narrow(1,1,1)
elseif img:size(1) ~= 1 then
Expand Down
2 changes: 1 addition & 1 deletion test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function flip_tests.test_transformation_largeByteImage(flip)
local x_real = image.fabio():double():mul(255)
local x_byte = x_real:clone():byte()

assert(x_byte:size(1) > 256 and x_byte:size(2) > 256, 'Tricky case only occurs for images larger than 256 px, pick another example')
assert(x_byte:size(2) > 256 and x_byte:size(3) > 256, 'Tricky case only occurs for images larger than 256 px, pick another example')

local f_real, f_byte
f_real = image[flip](x_real)
Expand Down