Comments (14)
Little update: It seems that chnsCompute
ignores this too, however if I'm inputting a grayscale image I only get one colorchannel. Looks like the number of input channels is used instead of the number of requested channels.
from acf.
acf/src/lib/acf/chnsCompute.cpp
Line 139 in 17b8da4
int Detector::chnsCompute(const MatP& IIn, const Options::Pyramid::Chns& pChnsIn, Detector::Channels& chns, bool isInit, MatLoggerType pLogger)
I'll add a few notes to help track the relevant code sections.
There is a field Field<Color> Options::Pyramid::Chns::pColor
in the input structure passed to chnsCompute(...)
and the input MatP
image comes with a dimension: int MatP::channels()
.
struct Color
{
Field<int> enabled;
Field<double> smooth;
Field<std::string> colorSpace;
void merge(const Color& src, int mode);
friend std::ostream& operator<<(std::ostream& os, const Color& src);
template <class Archive>
void serialize(Archive& ar, const uint32_t version);
};
In your case first scenario, you are passing in a 3 channel RGB image and are requesting colorSpace == "gray"
. It should return a single color channel, but instead you are getting 3 channels, where the first one is grayscale. We don't want the second two.
Assuming that is correct, I can try to reproduce it this weekend. Feel free to send a fix if you have one.
acf/src/lib/acf/chnsCompute.cpp
Line 222 in 1c9fa31
rgbConvert(I, I, p.colorSpace, true);
☝️ It looks like I
is use as an input and output type here. I believe the output type should be (re)allocated using the channel count of the colorspace specified by p.colorSpace
:
acf/src/lib/acf/rgbConvert.cpp
Line 109 in 1c9fa31
int Detector::rgbConvert(const MatP& IIn, MatP& J, const std::string& colorSpace, bool useSingle, bool isLuv)
{
// <SNIP>
if (!IIn.empty() && (flag != 1) && (flag != 4))
{
rgbConvertMex(IIn, J, flag, useSingle);
}
acf/src/lib/acf/toolbox/rgbConvertMex.cpp
Lines 385 to 387 in 1c9fa31
J.create(I.size(), I.depth(), I.channels());
float* pJ = J.ptr<float>();
rgbConvert(const_cast<float*>(pI), pJ, I.size().area(), I.channels(), flag, float(nrm));
from acf.
In your case first scenario, you are passing in a 3 channel RGB image and are requesting colorSpace == "gray". It should return a single color channel, but instead you are getting 3 channels, where the first one is grayscale. We don't want the second two.
Exactly. If I simply change the input image from a rgb image to a grayscale image without modifying any other param I get only one color channel as output. For now I'm simply removing those two channels after converting them to std::vector<cv::Mat>
but obviously that's far from efficient.
from acf.
This should be fixed in the latest version.
from acf.
Hi, sry for the late feedback: I've updated the library today and noticed that apparently there's still an issue. Scenario is still the same, I've an image which is usually a color image but can also be a grayscale image and I set colorSpace
to gray
. While the number of outputed channels is now correct (always 8) the computed channels seem to be wrong:
- Input color image and calculating the whole pyramid returns proper channels and scales
- Input gray image and calculating only the channels returns proper channels
- Input color image and calculating only the channels returns black images
I've tested this with my own function (managing options on my own and directly callingchnsCompute
) and usingcomputeChannels
where I modified the setting ( https://github.com/elucideye/acf/blob/master/src/lib/acf/ACF.cpp#L202 ).
I've debugged this a bit and noticed a few things:
rgbConvert
is called with wrong parameters inchnsCompute
: https://github.com/elucideye/acf/blob/master/src/lib/acf/chnsCompute.cpp#L221 (The fourth param isuseSingle
which is set to true inchnsPyramid
: https://github.com/elucideye/acf/blob/master/src/lib/acf/chnsPyramid.cpp#L247 )chnsPyramid
contains an unnecessaryif
: https://github.com/elucideye/acf/blob/master/src/lib/acf/chnsPyramid.cpp#L231-L233- In
chnsPyramid
you check forI.channels()
before converting the image, however inchnsCompute
you don't
However the main issue with black images is apparently caused by using the same MatP
object for input and output rbgConvert(I, I, ...)
. When changing this to MatP t; rbgConvert(I, t, ...); I = t;
everything runs normally again. Note that chnsPyramid
doesn't have this issue as it already uses differenct objects for input and output.
from acf.
Okay, thanks for the update. I'll re-open this and sort through it more carefully.
from acf.
Any Update on this one? Really would like to see an official fix for this instead of my workaround.
from acf.
I've added a date for this one and will work on a fix this weekend. The notes above are helpful. For conciseness, Can you also share a small Matlab code sample to illustrate the expected behavior? Something like this
I=imread('dodecagon.png') * 255; % force [0 ... 255]
pPyramid=chnsPyramid();
P2=chnsPyramid(I,pPyramid);
splitA = num2cell(P2.data{1}, [1 2]);
P2_montage = horzcat(splitA{:});
imwrite(P2_montage, '/tmp/acf_matlab.png');
from acf.
Sure though the dodecagon seems to result in an black image anyways so I've used an image from the dataset I'm using:
I=imread('traffic.jpg');
pPyramid=chnsPyramid();
pPyramid.pChns.pColor.colorSpace = 'gray';
P2=chnsPyramid(I,pPyramid);
splitA = num2cell(P2.data{1}, [1 2]);
P2_montage = horzcat(splitA{:});
imwrite(P2_montage, '/tmp/acf_matlab.png');
from acf.
--color gray
polly.py --toolchain xcode --config Release --fwd HUNTER_CONFIGURATION_TYPES=Release --install
_install/xcode/bin/acf-pyramid --input=${HOME}/Downloads/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8.jpg --output=/tmp --colorspace gray
montage -tile 8x -border 0 -geometry +0+0 /tmp/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8_*_*_*.png /tmp/pyramid_gray.jpg
from acf.
--color luv
polly.py --toolchain xcode --config Release --fwd HUNTER_CONFIGURATION_TYPES=Release --install
_install/xcode/bin/acf-pyramid --input=${HOME}/Downloads/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8.jpg --output=/tmp --colorspace luv
montage -tile 10x -border 0 -geometry +0+0 /tmp/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8_*_*_*.png /tmp/pyramid_luv.jpg
from acf.
--color rgb
polly.py --toolchain xcode --config Release --fwd HUNTER_CONFIGURATION_TYPES=Release --install
_install/xcode/bin/acf-pyramid --input=${HOME}/Downloads/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8.jpg --output=/tmp --colorspace rgb
montage -tile 10x -border 0 -geometry +0+0 /tmp/40408926-7e6499ae-5e69-11e8-9573-3fc8f15385c8_*_*_*.png /tmp/pyramid_rgb.jpg
from acf.
@JN-Jones: The above were created with #80 which adds --colorspace
to the acf-pyramid
console utility, but the actual lib updates are already merged. Let me know if that doesn't address your use case.
from acf.
Seems to be fixed, thanks
from acf.
Related Issues (20)
- Execute issues in cross platform board HOT 13
- build issues for X86 Linux HOT 4
- acf shared library link ogles_gpgpu errors HOT 2
- Xcode 10.2 build failure
- Ubuntu 18.04 w/ gcc-5-pic-hid-sections-lto HOT 5
- Ubuntu 18.04 w/ linux-gcc-armhf-neon HOT 5
- Support OpenGL ES 2.0/3.0 on Desktop systems HOT 1
- 's|HUNTER_PROJECT_NAME|ELUCIDEYE_PROJECT_NAME|g' or similar
- Confusing installation
- convTri is not correctly called when calculating the pyramid HOT 2
- add pixel level acf pyramid tests : c++ vs matlab
- gradient hist channels are swapped HOT 6
- doxygen api docs
- https://github.com/jmbuena/toolbox.badacost.faces.public
- ACF_BUILD_OGLES_GPGPU=OFF broken HOT 1
- `GIT_SELF` package test HOT 1
- api tests vs unit tests HOT 5
- promote GPUDetectionPipeline to public API
- acf model parsing edge cases HOT 1
- ogles_gpgpu compile error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acf.