I have a program that will load an image from the hard disk. The program is written using emgu cv and the image is a Bgr image. I want to allow the user to increase/decrease the brightness/contrast of the image. How can I do this? Some sample code would be appreciated (because I am still a newbie). Thanks.
It depends on your image adjustment requirements.
You can start using some basic techniques already wrapped in emguCV such as histogram equalization and gamma correction. You can also combine them to achieve better result.
Image<Bgr, byte> inputImage;
inputImage._EqualizeHist();
inputImage._GammaCorrect(1.8d);
Related
I'm trying to find contours to convert image to dxf file. as you see this is the image which I work on.
Image<Gray, byte> imgOut = img.Convert<Gray, byte>()
.ThresholdBinary(new Gray(100), new Gray(255));
when I use find contours and then draw them in a new image I got this
when I use contours to get my dxf file I get this
So In result of the lines are bold and thick Emgucv threat them as they are closed polylines not single lines.
what should I do?
What is the goal to clearify your question?
If you are looking for the geometric objects of the drawing you can find it directly inside the dxf file without use of EmguCV. Probably the wall and helper lines are not on the same layer. This will help to analyze features such as the area of the flat. This information is lost when you are looking on the b/w image.
If you are looking for low level features like connected components this post about Blob can help you. It's base on FindCountours().
Using OpenCV 2.4.2 C/C++
I am trying to use the copyTo function to add a binary CV_8UC1 image to a RGB CV_8UC3 image. However, it seems to crash the program whenever I do this. I'm assuming that the difference in the number of channels doesn't allow me to add them. Is there some type of conversion that can allow me to use this copyTo function? I'm stitching a camera feed with its thresholded image side by side.
I'm using src.copyTo(dst(Rect(x,y,w,h))); as the copying code, and inRange(src,Scalar(#,#,#),Scalar(#,#,#),dst) as the thresholding operation.
I've tried to use the convertTo function but not having much luck with it. Can anyone give some advice?
Thanks
You should use cv::cvtColor function, which can convert from one color space to another. Look here for details.
I'm looking for a possibility to convert raster images to vector data using OpenCV. There I found a function cv::findContours() which seems to be a bit primitive (more probably I did not understand it fully):
It seems to use b/w images only (no greyscale and no coloured images) and does not seem to accept any filtering/error suppresion parameters that could be helpful in noisy images, to avoid very short vector lines or to avoid uneven polylines where one single, straight line would be the better result.
So my question: is there a OpenCV possibility to vectorise coloured raster images where the colour-information is assigned to the resulting polylinbes afterwards? And how can I apply noise reduction and error suppression to such a algorithm?
Thanks!
If you want to raster image by color than I recommend you to clusterize image on some group of colors (or quantalize it) and after this extract contours of each color and convert to needed format. There are no ready vectorizing methods in OpenCV.
What's the best set of image preprocessing operations to apply to images for text recognition in EmguCV?
I've included two sample images here.
Applying a low or high pass filter won't be suitable, as the text may be of any size. I've tried median and bilateral filters, but they don't seem to affect the image much.
The ideal result would be a binary image with all the text white, and most of the rest black. This image would then be sent to the OCR engine.
Thanks
There's nothing like the best set. Keep in mind that digital images can be acquired by different capture devices and each device can embed its own preprocessing system (filters) and other characteristics that can drastically change the image and even add noises to them. So every case would have to be treated (preprocessed) differently.
However, there are commmon operations that can be used to improve the detection, for instance, a very basic one would be to convert the image to grayscale and apply a threshold to binarize the image. Another technique I've used before is the bounding box, which allows you to detect the text region. To remove noises from images you might be interested in erode/dilate operations. I demonstrate some of these operations on this post.
Also, there are other interesting posts about OCR and OpenCV that you should take a look:
Simple Digit Recognition OCR in OpenCV-Python
Basic OCR in OpenCV
Now, just to show you a simple approach that can be used with your sample image, this is the result of inverting the color and applying a threshold:
cv::Mat new_img = cv::imread(argv[1]);
cv::bitwise_not(new_img, new_img);
double thres = 100;
double color = 255;
cv::threshold(new_img, new_img, thres, color, CV_THRESH_BINARY);
cv::imwrite("inv_thres.png", new_img);
Try morphological image processing. Have a look at this. However, it works only on binary images - so you will have to binarize the image( threshold?). Although, it is simple, it is dependent on font size, so one structure element will not work for all font sizes. If you want a generic solution, there are a number of papers for text detection in images - A search of this term in google scholar should provide you with some useful publications.
I am stuck with reading, processing and displaying sample.png image which
contains RGB and an additional Alpha layer.
I have manually removed background in this image and only foreground appears in
windows image slideshow propgram. I couldnt find any useful information
anywhr... when i read it from opencv usng functions imread or cvloadimage it
creates a white background by itself... i have read documentation of highgui
which states that these functions only deal wth RGB not RGBA...any help or idea
will be helpful...
Thanks
Saleh...
AFAIK only current solution is to load alpha channel as separate image and then join it together. You can use cvtColor() to add alpha channel to Mat with image and e.g. mixChannels() to mix it together with loaded aplha image.
You can use cv::imread() with IMREAD_UNCHANGED option, to read the data to a cv::Mat structure. If you still need an IplImage to work with, it is possible to convert from cv::Mat to IplImage without losing the alpha channel.