#include <string>
#include "20140318 Calculate the area of a class .cpp" //////////////////////////////////////////////////////////////////////////
// The name of the function : histeq()
// Pass in the parameter :
// BYTE*dstData Pointer to the memory space of the incoming grayscale image
// double *srcArray Histogram accumulation of template , And normalize it , The size is 256
// int m_Width Match the width of memory space
// int m_Height Match the height of memory space
// int m_pitch Match the memory size of each row of memory space
//////////////////////////////////////////////////////////////////////// void histeq(int **dstData, double *srcArray,int m_Width,int m_Height,int m_pitch)
{
//void *memset(void *s,int c,size_t n) Will have opened up memory space s The head of n Set the value of bytes to the value c
m_pitch=sizeof(data[][])*nXSize;
double dstHist[];
memset(dstHist,, * sizeof(double));
double dstArray[];
memset(dstArray,, * sizeof(double));
int i=,j=;
// Statistical histogram
for (i = ;i < m_Height;i++)
{
for (j = ;j < m_Width;j++)
{
dstHist[(int)dstData[i * m_pitch + j]]++;
}
}
// Calculate histogram accumulation
double m_Bytes = m_Width * m_Height;//m_Bytes Initialize to the total number of pixels
dstArray[] = dstHist[];// The first initialization is dstHist[0]=0
for (i = ;i < ;i++)
{
dstArray[i] = dstArray[i - ] + dstHist[i];
}
// Histogram cumulative normalization
for (i = ;i < ;i++)
{
dstArray[i] /= m_Bytes;
}
// Histogram matching
double m_diffA,m_diffB;
int k = ;
float mapPixel[];// Every color of value
memset(mapPixel,, * sizeof(float)); for (i = ;i < ;i++)
{
m_diffB = ;
for (j = k; j < ;j++)
{
m_diffA = abs(dstArray[i] - srcArray[j]);
if (m_diffA - m_diffB < 1.0E-5)
{
m_diffB = m_diffA;
k = j;
}
else
{
k = j - ;
break;
}
}
if (k == )
{
for (int l = i;l < ;l++)
{
mapPixel[l] = (float) k;
}
break;
}
mapPixel[i] = (float) k;
}
// Target image lookup index table
for (i = ;i < m_Height;i++)
{
for (j = ;j < m_Width;j++)
{
dstData[i * m_pitch + j] = mapPixel[(int)dstData[i * m_pitch + j]];
}
}
}

The gray-scale algorithm C++ More articles about

  1. be based on FPGA Of HDTV Video image gray histogram statistical algorithm design

    With HDTV The popularity of , With LCD-TV High definition digital TV, which is mainly based on digital TV, has gradually entered a period of vigorous development . With the traditional CRT What's different about TV is , These HDTV need more complex video processing circuit to drive , such as : A / D conversion (A/D Converter). Go to the next line ...

  2. Yes ​O​p​e​n​C​V​ straight ​ Fang ​ chart ​ Of ​ Count ​ According to the ​ junction ​ structure ​C​v​H​i​s​t​o​g​r​a​m​ Of ​ The reason is ​ Explain

    I was killed a few days ago OpenCV The histogram of the data structure CvHistogram It's very tangled . The Internet search , I don't have any information . Now I have a clue , Just write something , Let the people in the back walk better . First look at it. CvHistogram The definition of : typ ...

  3. [EmguCV|WinForm] Use EmguCV Build in histogram tool to draw histogram (Histogram)- Histogram (Histogram) series (1)

    https://dotblogs.com.tw/v6610688/archive/2013/12/20/emgucv_draw_histogram_histogrambox_histogramview ...

  4. matplotlib Study diary ( Four )- Draw straight statistical graph

    ( One ) Histogram - Applied to qualitative data visualization scenarios or discrete data , A bar chart is similar to a bar chart , It's just a function barh import matplotlib as mpl import matplotlib.pyplot a ...

  5. Opencv—— Three algorithms of color image graying

    In order to speed up the processing speed, in the image processing algorithm , It is often necessary to convert color image into gray image .24 Use... For each pixel of a color image 3 Byte representation , Each byte corresponds to RGB The brightness of the component . When RGB When the component values are different , In color images : When RGB When the components are the same , change ...

  6. Learn more OpenCV The principle of image graying in , Image similarity algorithm

    Recently, what I have learned and done is to process images , In fact, I am also a novice , Various attempts , So I, a layman, want to sum up what I have learned , The flow of image processing . But start to sum up , I don't know what I'm going to write , Then search the similar pictures you've done ...

  7. OpenCV Feature point detection algorithm comparison

    Overview of recognition algorithms : SIFT/SURF Based on grayscale , One . First, build the image pyramid , Form a three-dimensional image space , adopt Hessian The matrix obtains the local maximum of each layer , And then around the extreme point 26 I'll do it at two points NMS, So we can get the rough feature points , ...

  8. Opencv And LBP features ( Algorithm )

    LBP(Local Binary Pattern), The local binary pattern , For a pixel with a radius r Draw a circle , Take... From the circle K A little bit ( It's usually 8), this K The value of a point ( The pixel value greater than the center point is 1, Otherwise 0) form K Bit binary number . This is local ...

  9. lecture3- Linear neurons and algorithms

    Hinton The third class This class is mainly about NN The output end of the common neurons , And then the point is how to use BP To calculate the partial derivatives , stay Hinton In this lesson , He offered him 1986 I participated in writing < Parallel distributed processing > The author of the first 8 Chapter ,49 ...

Random recommendation

  1. isomerism SOA System architecture of Asp.net Realization ( compatible dubbo)

    The technical department of our company is quite complicated , Divided into groups , Each group may be divided into several departments , Each department may be divided into several groups , The organizational structure is complex , More developers . The programming language used is also a bit complicated , The mainstream languages are .net(C#).Java. ...

  2. Forbidden You don&#39;t have permission to access / on this server PHP

    In the newly installed Google tour , I can't fight PHP The web site , Error display : Forbidden You don't have permission to access / on this server. The reason is configuration permissions ...

  3. nyoj 712 explore Look for treasure hidden -- Minimum cost and maximum flow

    problem D: explore Look for treasure hidden The time limit : 1 Sec   Memory limit : 128 MB Title Description Legend has it that HMH There is one in the desert M*N maze , There are many treasures in it . One day ,Dr.Kong Found the map of the maze , He found the maze full of ...

  4. sublime Remove installed plug-ins

    If you want to remove the plug-in ,Ctrl+Shift+P Call up the command panel , Input remove, Call out Remove Package Option and enter , Select the plug-in to delete

  5. MVC-04 View (3)

    5、 ... and .Url Auxiliary method Url Auxiliary methods and HTML The auxiliary method is very similar ,HTML Auxiliary methods are used to produce HTML label , and Url Auxiliary methods are responsible for generating Url website . @Url.Action("About" ...

  6. Over brain series :Nokia The road of no return

    No data , No investigation , Just suddenly thinking of Nokia ... 23 A soy sauce lesson on the 5th , Two key words flashed through my mind --nokia & android So I used my mobile phone to Baidu , There's a new model ,NokiaX,X In the east 24 Japan ...

  7. Intent Several kinds of Flag Different

    It's a bit cold in winter , I don't want to blog . Study Intent Several kinds of Flag Different : 1,FLAG_ACTIVITY_CLEAR_TOP: They'll clean up the targets activity Everything on the stack activity Intent inte ...

  8. ( Reprint ) Siemens PLC Study notes 15 -( Data block and data access mode )

    One . Data blocks The data block is in S7 CPU Defined in the memory of , Users can define more data blocks , however CPU There are limits on the number of data blocks and the total amount of data . Data blocks are different from temporary data , When the logical block execution ends or the data block closes , The data in the data block will be retained ...

  9. html Classification and characteristics of elements

    Explain a few concepts : Replacement elements : The official explanation is , A content is not affected by css Visual formatting model control ,css Rendering models do not consider rendering of this content , And the elements generally have a fixed size ,( Height , Width ) The elements of , It's called the displacement element . Generally speaking, the browser is based on ...

  10. php Next webservice Use summary

    be based on thinkphp3.2 Of 1. modify php To configure php.ini extension=php_soap.dll soap.wsdl_cache_enabled=0 2.soap There are two patterns wsdl and ...