getBasePtr
Syntax
Description
Examples
Perform Histogram Equalization by Using OpenCV in MATLAB
Perform histogram equalization of an image by using the prebuilt MATLAB interface to the OpenCV function cv::CLAHE
. The cv::CLAHE
function is a base class, and you must create a MATLAB interface object by using the getBasePtr
utility function to access the public methods and attributes of the base class.
Add the MATLAB interface to OpenCV package names to the import list.
import clib.opencv.*; import vision.opencv.util.*;
Read an image into the MATLAB workspace.
img = imread("cameraman.tif");
Create the MATLAB interface objects for the OpenCV MatND
and InputArray
classes to store the input image.
[inputMat,inputArray] = createMat(img);
Create the MATLAB interface objects for the OpenCV MatND
and OutputArray
classes to write the output image returned by the OpenCV function.
[outputMat,outputArray] = createMat;
Create a MATLAB interface object to represent the smart pointer of the OpenCV CLAHE class cv::CLAHE
.
ocvPtr = cv.createCLAHE;
Create a MATLAB interface object for the base class cv::CLAHE
.
basePtr = getBasePtr(ocvPtr);
Set the value of clip limit to 4
.
basePtr.setClipLimit(4);
Perform contrast-limited adaptive histogram equalization by using the apply
method of the cv::CLAHE
base class.
basePtr.apply(inputArray,outputArray);
Read the enhanced output image.
enhanced = getImage(outputArray);
Display the original input and the enhanced output image.
figure
imshow(img)
title("Input Image")
figure
imshow(enhanced)
title("Enhanced Image")
Input Arguments
ptr
— OpenCV smart pointer
Ptr_cv_<_T>
interface object
OpenCV smart pointer, specified as a Ptr_cv_<_T>
interface
object. This MATLAB interface object is a representation of an OpenCV smart pointer
cv::Ptr<_T>
.
Output Arguments
output
— Representation of OpenCV base class
MATLAB interface object
Representation of OpenCV base class, returned as a MATLAB interface object. You can use the object to directly access the public member functions and public attributes of an OpenCV base class.
Version History
Introduced in R2021b
See Also
rectToBbox
| getImage
| createMat
| keyPointsToStruct
| createUMat
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)