-
Notifications
You must be signed in to change notification settings - Fork 4
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
Adding read-image folder #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work, @verma-ananya. I left some minor comments. It will be great if we can:
- Add an example to resize an image using
stb_image_resize
library. - Add self explanatory comments in the code, to allow future changes.
- Compare performance of OpenCV
imread
withstbi_load
function.
Also, looking at the basic usage of stbi_load
from https://github.com/nothings/stb/blob/master/stb_image.h#L124:
// Basic usage:
// int x,y,n;
// unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
// // ... process data if not NULL ...
// // ... x = width, y = height, n = # 8-bit components per pixel ...
// // ... replace '0' with '1'..'4' to force that many components per pixel
// // ... but 'n' will always be the number that it would have been if you said 0
// stbi_image_free(data)
From what I understand, the fourth argument is number of channels in the input image, and fifth argument is the output number of channels that we want in our image (I may be wrong). If this is true, then does it also mean that the user needs to know the number of channels in their dataset while using stbi_load
function?
@@ -0,0 +1,14 @@ | |||
#include <stdint.h> | |||
|
|||
#define STB_IMAGE_IMPLEMENTATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any note on why this definition is needed?
##include <stdint.h> | ||
|
||
#define STB_IMAGE_IMPLEMENTATION | ||
#include "stb_image.h" | ||
|
||
int main() { | ||
int width, height, bpp; | ||
|
||
uint8_t* rgb_image = stbi_load("sky.jpg", &width, &height, &bpp, 3); | ||
|
||
stbi_image_free(rgb_image); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this (image.cpp~
) a possible duplicate of image.cpp
file?
Closing this PR as this has been taken over by myself. I'll experiment using Selene! (https://github.com/kmhofmann/selene) |
Following offline discussion with @krshrimali, we want to find a way to remove OpenCV dependency from the project. This will enable users to not require building OpenCV from source, which can create issues (see: https://github.com/opencv/opencv/issues?q=is%3Aopen+is%3Aissue+label%3A%22category%3A+build%2Finstall%22).
This PR attempts to start discussion on this topic. The first attempt is to compare using
stb
libraries for reading an image and resizing. Including the header files will be easier, and it will avoid the requirement to build the whole library (like OpenCV). This saves time, efforts but performance metric needs to be looked after.Currently, this PR contains:
cc: @krshrimali