SlideShare a Scribd company logo
1 of 2
Download to read offline
histogram.txt
code by Iry - document created on 13 Nov - what-o.com@hotmail.com
void CMy04Dlg::CalcHistogram(IplImage* img, int c)
{
IplImage* channel = cvCreateImage( cvGetSize(img), 8, 1 );
IplImage *hist_img = cvCreateImage(cvSize(100,100), 8, 3);
cvSet( hist_img, cvScalarAll(255), 0 );
CvHistogram *hist_red;
CvHistogram *hist_green;
CvHistogram *hist_blue;
int hist_size = 256;
float range[]={0,256};
float* ranges[] = { range };
float max_value = 0.0;
float max = 0.0;
float w_scale = 0.0;
/* Create a 1-D Arrays to hold the histograms */
hist_red = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
hist_green = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
hist_blue = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
/* Set image to obtain RED as Channel of Interest (COI) */
cvSetImageCOI(img,3);
cvCopy(img,channel);
cvResetImageROI(img);
/* Calculate histogram of the Image and store it in the array */
cvCalcHist( &channel, hist_red, 0, NULL );
/* Calculate and Plot the histograms Green and Blue channels as well */
/* Green channel */
cvSetImageCOI(img,2);
cvCopy(img,channel);
cvResetImageROI(img);
cvCalcHist( &channel, hist_green, 0, NULL );
/* Blue channel */
cvSetImageCOI(img,1);
cvCopy(img,channel);
cvResetImageROI(img);
cvCalcHist( &channel, hist_blue, 0, NULL );
/* Find the minimum and maximum values of the histograms */
cvGetMinMaxHistValue( hist_red, 0, &max_value, 0, 0 );
cvGetMinMaxHistValue( hist_green, 0, &max, 0, 0 );
max_value = (max > max_value) ? max : max_value;
cvGetMinMaxHistValue( hist_blue, 0, &max, 0, 0 );
max_value = (max > max_value) ? max : max_value;
// The variable max_value has the maximum of the three histograms
/* Using the maximum value, Scale/Squeeze the histogram (to fit the image)
*/
cvScale( hist_red->bins, hist_red->bins,
Page 1
histogram.txt
((float)hist_img->height)/max_value, 0 );
cvScale( hist_green->bins, hist_green->bins,
((float)hist_img->height)/max_value, 0 );
cvScale( hist_blue->bins, hist_blue->bins,
((float)hist_img->height)/max_value, 0 );
/* Scale/Squeeze the histogram range to image width */
w_scale = ((float)hist_img->width)/hist_size;
/* Plot the Histograms */
for( int i = 0; i < hist_size; i++ )
{
cvRectangle( hist_img, cvPoint((int)i*w_scale ,
hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height -
cvRound(cvGetReal1D(hist_red->bins,i))),CV_RGB(255,0,0), -1, 8, 0 );
cvRectangle( hist_img, cvPoint((int)i*w_scale ,
hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height -
cvRound(cvGetReal1D(hist_green->bins,i))),CV_RGB(0,255,0), -1, 8, 0 );
cvRectangle( hist_img, cvPoint((int)i*w_scale ,
hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height -
cvRound(cvGetReal1D(hist_blue->bins,i))),CV_RGB(0,0,255), -1, 8, 0 );
}
ShowImage( hist_img, IDC_IHist );
cvSaveImage("myoutput_10nov.jpg",hist_img);
}
Page 2

More Related Content

What's hot

library(tidyr) and library(ggplot2)
library(tidyr)  and library(ggplot2)library(tidyr)  and library(ggplot2)
library(tidyr) and library(ggplot2)Dr. Volkan OBAN
 
Code sources des fonctions table cp
Code sources des fonctions table cpCode sources des fonctions table cp
Code sources des fonctions table cpidhem110
 
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)Shift Conference
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-arrayDeepak Singh
 
Use of django at jolt online v3
Use of django at jolt online v3Use of django at jolt online v3
Use of django at jolt online v3Jaime Buelta
 
[論文紹介] Towards Understanding Linear Word Analogies
[論文紹介] Towards Understanding Linear Word Analogies[論文紹介] Towards Understanding Linear Word Analogies
[論文紹介] Towards Understanding Linear Word AnalogiesMakoto Takenaka
 
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Bjarni Kristjánsson
 
Shortest Path Search with pgRouting
Shortest Path Search with pgRoutingShortest Path Search with pgRouting
Shortest Path Search with pgRoutingFOSS4G 2011
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in RIlya Zhbannikov
 
Cryptocurrency ecosystem(together society)
Cryptocurrency ecosystem(together society)Cryptocurrency ecosystem(together society)
Cryptocurrency ecosystem(together society)jihong yang
 
Coq for ML users
Coq for ML usersCoq for ML users
Coq for ML userstmiya
 
Monads from Definition
Monads from DefinitionMonads from Definition
Monads from DefinitionDierk König
 

What's hot (19)

library(tidyr) and library(ggplot2)
library(tidyr)  and library(ggplot2)library(tidyr)  and library(ggplot2)
library(tidyr) and library(ggplot2)
 
Code sources des fonctions table cp
Code sources des fonctions table cpCode sources des fonctions table cp
Code sources des fonctions table cp
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
 
Stomata Membrane
Stomata MembraneStomata Membrane
Stomata Membrane
 
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)
A, B, C. 1, 2, 3. Iterables you and me - Willian Martins (ebay)
 
Proga 090525
Proga 090525Proga 090525
Proga 090525
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
Irs gan doc
Irs gan docIrs gan doc
Irs gan doc
 
Use of django at jolt online v3
Use of django at jolt online v3Use of django at jolt online v3
Use of django at jolt online v3
 
[論文紹介] Towards Understanding Linear Word Analogies
[論文紹介] Towards Understanding Linear Word Analogies[論文紹介] Towards Understanding Linear Word Analogies
[論文紹介] Towards Understanding Linear Word Analogies
 
bitman.c
bitman.cbitman.c
bitman.c
 
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
Maximal: Comparison of Optimization Modeling Software for Python - Oct 2012
 
Shortest Path Search with pgRouting
Shortest Path Search with pgRoutingShortest Path Search with pgRouting
Shortest Path Search with pgRouting
 
Joclad 2010 d
Joclad 2010 dJoclad 2010 d
Joclad 2010 d
 
Advanced Concepts in Python
Advanced Concepts in PythonAdvanced Concepts in Python
Advanced Concepts in Python
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
Cryptocurrency ecosystem(together society)
Cryptocurrency ecosystem(together society)Cryptocurrency ecosystem(together society)
Cryptocurrency ecosystem(together society)
 
Coq for ML users
Coq for ML usersCoq for ML users
Coq for ML users
 
Monads from Definition
Monads from DefinitionMonads from Definition
Monads from Definition
 

Similar to Histogram

Histogram dan Segmentasi
Histogram dan SegmentasiHistogram dan Segmentasi
Histogram dan SegmentasiLusiana Diyan
 
Histogram dan Segmentasi 2
Histogram dan Segmentasi 2Histogram dan Segmentasi 2
Histogram dan Segmentasi 2Lusiana Diyan
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdffashiongallery1
 
Deep Learning with Julia1.0 and Flux
Deep Learning with Julia1.0 and FluxDeep Learning with Julia1.0 and Flux
Deep Learning with Julia1.0 and FluxSatoshi Terasaki
 
C++ Find the largest complex number in an array using recursive met.pdf
C++ Find the largest complex number in an array using recursive met.pdfC++ Find the largest complex number in an array using recursive met.pdf
C++ Find the largest complex number in an array using recursive met.pdfalvisguyjhiy
 
Tomato Classification using Computer Vision
Tomato Classification using Computer VisionTomato Classification using Computer Vision
Tomato Classification using Computer VisionRaman Pandey
 
ARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationGilbert Guerrero
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processingChu Lam
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
Write a Matlab code (a computerized program) for calculating plane st.docx
 Write a Matlab code (a computerized program) for calculating plane st.docx Write a Matlab code (a computerized program) for calculating plane st.docx
Write a Matlab code (a computerized program) for calculating plane st.docxajoy21
 
Some examples of the 64-bit code errors
Some examples of the 64-bit code errorsSome examples of the 64-bit code errors
Some examples of the 64-bit code errorsPVS-Studio
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays Reem Alattas
 

Similar to Histogram (20)

Histogram dan Segmentasi
Histogram dan SegmentasiHistogram dan Segmentasi
Histogram dan Segmentasi
 
Histogram dan Segmentasi 2
Histogram dan Segmentasi 2Histogram dan Segmentasi 2
Histogram dan Segmentasi 2
 
Open Cv Tutorial Ii
Open Cv Tutorial IiOpen Cv Tutorial Ii
Open Cv Tutorial Ii
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 
Deep Learning with Julia1.0 and Flux
Deep Learning with Julia1.0 and FluxDeep Learning with Julia1.0 and Flux
Deep Learning with Julia1.0 and Flux
 
C++ Find the largest complex number in an array using recursive met.pdf
C++ Find the largest complex number in an array using recursive met.pdfC++ Find the largest complex number in an array using recursive met.pdf
C++ Find the largest complex number in an array using recursive met.pdf
 
Tomato Classification using Computer Vision
Tomato Classification using Computer VisionTomato Classification using Computer Vision
Tomato Classification using Computer Vision
 
ARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using Randomization
 
Awt components
Awt componentsAwt components
Awt components
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer
 
Write a Matlab code (a computerized program) for calculating plane st.docx
 Write a Matlab code (a computerized program) for calculating plane st.docx Write a Matlab code (a computerized program) for calculating plane st.docx
Write a Matlab code (a computerized program) for calculating plane st.docx
 
Arrays & Strings.pptx
Arrays & Strings.pptxArrays & Strings.pptx
Arrays & Strings.pptx
 
Canvas
CanvasCanvas
Canvas
 
Canvas
CanvasCanvas
Canvas
 
Statistics.cpp
Statistics.cppStatistics.cpp
Statistics.cpp
 
Some examples of the 64-bit code errors
Some examples of the 64-bit code errorsSome examples of the 64-bit code errors
Some examples of the 64-bit code errors
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Histogram

  • 1. histogram.txt code by Iry - document created on 13 Nov - what-o.com@hotmail.com void CMy04Dlg::CalcHistogram(IplImage* img, int c) { IplImage* channel = cvCreateImage( cvGetSize(img), 8, 1 ); IplImage *hist_img = cvCreateImage(cvSize(100,100), 8, 3); cvSet( hist_img, cvScalarAll(255), 0 ); CvHistogram *hist_red; CvHistogram *hist_green; CvHistogram *hist_blue; int hist_size = 256; float range[]={0,256}; float* ranges[] = { range }; float max_value = 0.0; float max = 0.0; float w_scale = 0.0; /* Create a 1-D Arrays to hold the histograms */ hist_red = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1); hist_green = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1); hist_blue = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1); /* Set image to obtain RED as Channel of Interest (COI) */ cvSetImageCOI(img,3); cvCopy(img,channel); cvResetImageROI(img); /* Calculate histogram of the Image and store it in the array */ cvCalcHist( &channel, hist_red, 0, NULL ); /* Calculate and Plot the histograms Green and Blue channels as well */ /* Green channel */ cvSetImageCOI(img,2); cvCopy(img,channel); cvResetImageROI(img); cvCalcHist( &channel, hist_green, 0, NULL ); /* Blue channel */ cvSetImageCOI(img,1); cvCopy(img,channel); cvResetImageROI(img); cvCalcHist( &channel, hist_blue, 0, NULL ); /* Find the minimum and maximum values of the histograms */ cvGetMinMaxHistValue( hist_red, 0, &max_value, 0, 0 ); cvGetMinMaxHistValue( hist_green, 0, &max, 0, 0 ); max_value = (max > max_value) ? max : max_value; cvGetMinMaxHistValue( hist_blue, 0, &max, 0, 0 ); max_value = (max > max_value) ? max : max_value; // The variable max_value has the maximum of the three histograms /* Using the maximum value, Scale/Squeeze the histogram (to fit the image) */ cvScale( hist_red->bins, hist_red->bins, Page 1
  • 2. histogram.txt ((float)hist_img->height)/max_value, 0 ); cvScale( hist_green->bins, hist_green->bins, ((float)hist_img->height)/max_value, 0 ); cvScale( hist_blue->bins, hist_blue->bins, ((float)hist_img->height)/max_value, 0 ); /* Scale/Squeeze the histogram range to image width */ w_scale = ((float)hist_img->width)/hist_size; /* Plot the Histograms */ for( int i = 0; i < hist_size; i++ ) { cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist_red->bins,i))),CV_RGB(255,0,0), -1, 8, 0 ); cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist_green->bins,i))),CV_RGB(0,255,0), -1, 8, 0 ); cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist_blue->bins,i))),CV_RGB(0,0,255), -1, 8, 0 ); } ShowImage( hist_img, IDC_IHist ); cvSaveImage("myoutput_10nov.jpg",hist_img); } Page 2