SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
why the code below is not running? Can you please fix it?
#include
#include
#include
using namespace std;
// Define the size of the images
const int M = 6;
const int N = 6;
// Define a function to compute the joint entropy given a co-occurrence matrix
double computeJointEntropy(vector>& coocMatrix) {
double jointEntropy = 0.0;
double sum = 0.0;
for (int k = 0; k < 2; k++) {
for (int l = 0; l < 2; l++) {
double pkl = coocMatrix[k][l];
if (pkl > 0) {
jointEntropy -= pkl * log2(pkl);
sum += pkl;
}
}
}
if (sum < 1.0) {
jointEntropy = 1.0;
}
return jointEntropy;
}
// Define a function to compute the similarity measure given a joint entropy value
double computeSimilarity(double jointEntropy, double maxJointEntropy) {
return 1.0 - jointEntropy / maxJointEntropy;
}
int main() {
// Define the reference image A
int A[M][N] = {
{1, 1, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 1},
{0, 0, 0, 1, 1, 1},
{0, 0, 0, 1, 1, 1}
};
// Define the database of binary images B
int B[10][M][N] = {
// Image 0
{
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1}
},
// Image 1
{
{0, 1, 1, 0, 0, 0},
{0, 1, 1, 0, 0, 0},
{0, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 0},
{0, 0, 0, 1, 1, 0},
{0, 0, 0, 1, 1, 0}
},
// Image 2
{
{1, 1, 0, 0, 0, 1},
{1, 1, 0, 0, 0, 1},
{1, 1, 0, 0, 0, 1},
{0, 0, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0},
#include
#include
#define M 6 // number of rows
#define N 6 // number of columns
#define NUM_IMAGES 10 // number of images in database
using namespace std;
int main() {
// Load reference image A and database images B(s)
// TODO: implement reading images from Excel file
// Initialize co-occurrence matrix C
int C[2][2] = {0};
// Compute co-occurrence matrix for reference image A
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
int K = /* TODO: compute intensity value of pixel (i,j) in image A */;
int L = /* TODO: compute intensity value of pixel (i,j) in image B(s) */;
C[K][L]++;
}
}
// Compute co-occurrence probability matrix P
double P[2][2] = {0};
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
P[i][j] = (double) C[i][j] / (M * N);
}
}
// Convert P to 1-D array and compute co-occurrence entropies H(s)
double H[NUM_IMAGES] = {0};
for (int s = 0; s < NUM_IMAGES; s++) {
// TODO: compute co-occurrence probability matrix for image B(s)
// TODO: convert P to 1-D array
for (int i = 0; i < 4; i++) {
double p = /* TODO: get i-th element of P 1-D array */;
if (p > 0) {
H[s] -= p * log2(p);
}
}
}
// Compute similarity measures rho(s)
double rho[NUM_IMAGES] = {0};
double max_H = *max_element(H, H + NUM_IMAGES);
for (int s = 0; s < NUM_IMAGES; s++) {
rho[s] = 1 - H[s] / max_H;
}
// Find index s_max of image B(s) that is most similar to reference image A
double max_rho = -1;
int s_max = -1;
for (int s = 0; s < NUM_IMAGES; s++) {
if (rho[s] > max_rho) {
max_rho = rho[s];
s_max = s;
}
}
// Output results
cout << "Co-occurrence probability matrix for a sample image from the database:" << endl;
// TODO: output P for a sample image
cout << "Co-occurrence entropies for the database images:" << endl;
for (int s = 0; s < NUM_IMAGES; s++) {
cout << "H(" << s << ") = " << H[s] << endl;
}
cout << "Similarity measures for the reference image with the database images:" << endl
Each image consists of 6 rows. Each row has 6 pixels {0,1}. See example on sheet 2

Contenu connexe

Similaire à why the code below is not running Can you please fix it #inc.pdf

C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
MO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptMO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptshashankbhadouria4
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesCUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesSubhajit Sahu
 
Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdffedosys
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...Michael Rys
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfgiriraj65
 
In this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfIn this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfcharanjit1717
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for SpeedYung-Yu Chen
 
AI02_Python (cont.).pptx
AI02_Python (cont.).pptxAI02_Python (cont.).pptx
AI02_Python (cont.).pptxNguyễn Tiến
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs偉格 高
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
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-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUadAccount
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6Nitay Neeman
 

Similaire à why the code below is not running Can you please fix it #inc.pdf (20)

C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
MO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.pptMO 2020 DS Applications of Linked List 1 AB.ppt
MO 2020 DS Applications of Linked List 1 AB.ppt
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesCUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
 
Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdf
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
Otsu
OtsuOtsu
Otsu
 
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
In this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfIn this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdf
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
AI02_Python (cont.).pptx
AI02_Python (cont.).pptxAI02_Python (cont.).pptx
AI02_Python (cont.).pptx
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Rcpp11 genentech
Rcpp11 genentechRcpp11 genentech
Rcpp11 genentech
 
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
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
 

Plus de amikoenterprises

Within MySQL Workbench, create a new table. This table will be used .pdf
Within MySQL Workbench, create a new table. This table will be used .pdfWithin MySQL Workbench, create a new table. This table will be used .pdf
Within MySQL Workbench, create a new table. This table will be used .pdfamikoenterprises
 
Within the unethical leadership presentation, I talked a lot about t.pdf
Within the unethical leadership presentation, I talked a lot about t.pdfWithin the unethical leadership presentation, I talked a lot about t.pdf
Within the unethical leadership presentation, I talked a lot about t.pdfamikoenterprises
 
Write a C program to create two user-defined functions; first functi.pdf
Write a C program to create two user-defined functions; first functi.pdfWrite a C program to create two user-defined functions; first functi.pdf
Write a C program to create two user-defined functions; first functi.pdfamikoenterprises
 
Write a C# program that demonstrate your multi-level inheritance und.pdf
Write a C# program that demonstrate your multi-level inheritance und.pdfWrite a C# program that demonstrate your multi-level inheritance und.pdf
Write a C# program that demonstrate your multi-level inheritance und.pdfamikoenterprises
 
With reference to the above case, please answer all of the followi.pdf
With reference to the above case, please answer all of the followi.pdfWith reference to the above case, please answer all of the followi.pdf
With reference to the above case, please answer all of the followi.pdfamikoenterprises
 
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdf
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdfWR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdf
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdfamikoenterprises
 
without using truth table Unit I Logic and Proofs Question 1. Is.pdf
without using truth table  Unit I Logic and Proofs Question 1. Is.pdfwithout using truth table  Unit I Logic and Proofs Question 1. Is.pdf
without using truth table Unit I Logic and Proofs Question 1. Is.pdfamikoenterprises
 
Working with Apache Web ServerTime Required 35 minutesObjective.pdf
Working with Apache Web ServerTime Required 35 minutesObjective.pdfWorking with Apache Web ServerTime Required 35 minutesObjective.pdf
Working with Apache Web ServerTime Required 35 minutesObjective.pdfamikoenterprises
 
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdf
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdfWilliam Short is chief executive officer (CEO) of Benton Memorial Ho.pdf
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdfamikoenterprises
 
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdf
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdfWord facilita el formato de texto usando negrita, cursiva y subrayad.pdf
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdfamikoenterprises
 
wo populations of beetles have different reproductive organs that ar.pdf
wo populations of beetles have different reproductive organs that ar.pdfwo populations of beetles have different reproductive organs that ar.pdf
wo populations of beetles have different reproductive organs that ar.pdfamikoenterprises
 
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdf
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdfWittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdf
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdfamikoenterprises
 
Write the necessary SQL Queries for the following functions.A,Addi.pdf
Write the necessary SQL Queries for the following functions.A,Addi.pdfWrite the necessary SQL Queries for the following functions.A,Addi.pdf
Write the necessary SQL Queries for the following functions.A,Addi.pdfamikoenterprises
 
Write the necessary SQL Queries for the following functions.A. Add.pdf
Write the necessary SQL Queries for the following functions.A. Add.pdfWrite the necessary SQL Queries for the following functions.A. Add.pdf
Write the necessary SQL Queries for the following functions.A. Add.pdfamikoenterprises
 
Write the class named Student which has the following data members.pdf
Write the class named Student  which has the following data members.pdfWrite the class named Student  which has the following data members.pdf
Write the class named Student which has the following data members.pdfamikoenterprises
 
Write program in C language to sort the given array using merge sort.pdf
Write program in C language to sort the given array using merge sort.pdfWrite program in C language to sort the given array using merge sort.pdf
Write program in C language to sort the given array using merge sort.pdfamikoenterprises
 
Write notes on the following areas as related to tax investigations .pdf
Write notes on the following areas as related to tax investigations .pdfWrite notes on the following areas as related to tax investigations .pdf
Write notes on the following areas as related to tax investigations .pdfamikoenterprises
 
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdf
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdfWrite it in Assembly codeWrite it in Assembly codeWrite it in As.pdf
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdfamikoenterprises
 
Write MATLAB code to solve this summation in general, where you can .pdf
Write MATLAB code to solve this summation in general, where you can .pdfWrite MATLAB code to solve this summation in general, where you can .pdf
Write MATLAB code to solve this summation in general, where you can .pdfamikoenterprises
 
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdf
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdfWilliam es due�o de un solo barco. El barco vale 200 millones de d�l.pdf
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdfamikoenterprises
 

Plus de amikoenterprises (20)

Within MySQL Workbench, create a new table. This table will be used .pdf
Within MySQL Workbench, create a new table. This table will be used .pdfWithin MySQL Workbench, create a new table. This table will be used .pdf
Within MySQL Workbench, create a new table. This table will be used .pdf
 
Within the unethical leadership presentation, I talked a lot about t.pdf
Within the unethical leadership presentation, I talked a lot about t.pdfWithin the unethical leadership presentation, I talked a lot about t.pdf
Within the unethical leadership presentation, I talked a lot about t.pdf
 
Write a C program to create two user-defined functions; first functi.pdf
Write a C program to create two user-defined functions; first functi.pdfWrite a C program to create two user-defined functions; first functi.pdf
Write a C program to create two user-defined functions; first functi.pdf
 
Write a C# program that demonstrate your multi-level inheritance und.pdf
Write a C# program that demonstrate your multi-level inheritance und.pdfWrite a C# program that demonstrate your multi-level inheritance und.pdf
Write a C# program that demonstrate your multi-level inheritance und.pdf
 
With reference to the above case, please answer all of the followi.pdf
With reference to the above case, please answer all of the followi.pdfWith reference to the above case, please answer all of the followi.pdf
With reference to the above case, please answer all of the followi.pdf
 
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdf
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdfWR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdf
WR Grace Company fue fundada por, s�, un hombre llamado WR Grace. Er.pdf
 
without using truth table Unit I Logic and Proofs Question 1. Is.pdf
without using truth table  Unit I Logic and Proofs Question 1. Is.pdfwithout using truth table  Unit I Logic and Proofs Question 1. Is.pdf
without using truth table Unit I Logic and Proofs Question 1. Is.pdf
 
Working with Apache Web ServerTime Required 35 minutesObjective.pdf
Working with Apache Web ServerTime Required 35 minutesObjective.pdfWorking with Apache Web ServerTime Required 35 minutesObjective.pdf
Working with Apache Web ServerTime Required 35 minutesObjective.pdf
 
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdf
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdfWilliam Short is chief executive officer (CEO) of Benton Memorial Ho.pdf
William Short is chief executive officer (CEO) of Benton Memorial Ho.pdf
 
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdf
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdfWord facilita el formato de texto usando negrita, cursiva y subrayad.pdf
Word facilita el formato de texto usando negrita, cursiva y subrayad.pdf
 
wo populations of beetles have different reproductive organs that ar.pdf
wo populations of beetles have different reproductive organs that ar.pdfwo populations of beetles have different reproductive organs that ar.pdf
wo populations of beetles have different reproductive organs that ar.pdf
 
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdf
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdfWittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdf
Wittes Tasty Fishes� Wittes Tasty Fishes� is an aquaculture compan.pdf
 
Write the necessary SQL Queries for the following functions.A,Addi.pdf
Write the necessary SQL Queries for the following functions.A,Addi.pdfWrite the necessary SQL Queries for the following functions.A,Addi.pdf
Write the necessary SQL Queries for the following functions.A,Addi.pdf
 
Write the necessary SQL Queries for the following functions.A. Add.pdf
Write the necessary SQL Queries for the following functions.A. Add.pdfWrite the necessary SQL Queries for the following functions.A. Add.pdf
Write the necessary SQL Queries for the following functions.A. Add.pdf
 
Write the class named Student which has the following data members.pdf
Write the class named Student  which has the following data members.pdfWrite the class named Student  which has the following data members.pdf
Write the class named Student which has the following data members.pdf
 
Write program in C language to sort the given array using merge sort.pdf
Write program in C language to sort the given array using merge sort.pdfWrite program in C language to sort the given array using merge sort.pdf
Write program in C language to sort the given array using merge sort.pdf
 
Write notes on the following areas as related to tax investigations .pdf
Write notes on the following areas as related to tax investigations .pdfWrite notes on the following areas as related to tax investigations .pdf
Write notes on the following areas as related to tax investigations .pdf
 
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdf
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdfWrite it in Assembly codeWrite it in Assembly codeWrite it in As.pdf
Write it in Assembly codeWrite it in Assembly codeWrite it in As.pdf
 
Write MATLAB code to solve this summation in general, where you can .pdf
Write MATLAB code to solve this summation in general, where you can .pdfWrite MATLAB code to solve this summation in general, where you can .pdf
Write MATLAB code to solve this summation in general, where you can .pdf
 
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdf
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdfWilliam es due�o de un solo barco. El barco vale 200 millones de d�l.pdf
William es due�o de un solo barco. El barco vale 200 millones de d�l.pdf
 

Dernier

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Dernier (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

why the code below is not running Can you please fix it #inc.pdf

  • 1. why the code below is not running? Can you please fix it? #include #include #include using namespace std; // Define the size of the images const int M = 6; const int N = 6; // Define a function to compute the joint entropy given a co-occurrence matrix double computeJointEntropy(vector>& coocMatrix) { double jointEntropy = 0.0; double sum = 0.0; for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { double pkl = coocMatrix[k][l]; if (pkl > 0) { jointEntropy -= pkl * log2(pkl); sum += pkl; } } } if (sum < 1.0) { jointEntropy = 1.0; } return jointEntropy; } // Define a function to compute the similarity measure given a joint entropy value double computeSimilarity(double jointEntropy, double maxJointEntropy) { return 1.0 - jointEntropy / maxJointEntropy; } int main() { // Define the reference image A int A[M][N] = {
  • 2. {1, 1, 1, 0, 0, 0}, {1, 1, 1, 0, 0, 0}, {1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 1} }; // Define the database of binary images B int B[10][M][N] = { // Image 0 { {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1} }, // Image 1 { {0, 1, 1, 0, 0, 0}, {0, 1, 1, 0, 0, 0}, {0, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 0}, {0, 0, 0, 1, 1, 0}, {0, 0, 0, 1, 1, 0} }, // Image 2 { {1, 1, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 1}, {0, 0, 1, 1, 1, 0}, {0, 0, 1, 1, 1, 0}, #include #include
  • 3. #define M 6 // number of rows #define N 6 // number of columns #define NUM_IMAGES 10 // number of images in database using namespace std; int main() { // Load reference image A and database images B(s) // TODO: implement reading images from Excel file // Initialize co-occurrence matrix C int C[2][2] = {0}; // Compute co-occurrence matrix for reference image A for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { int K = /* TODO: compute intensity value of pixel (i,j) in image A */; int L = /* TODO: compute intensity value of pixel (i,j) in image B(s) */; C[K][L]++; } } // Compute co-occurrence probability matrix P double P[2][2] = {0}; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { P[i][j] = (double) C[i][j] / (M * N); } } // Convert P to 1-D array and compute co-occurrence entropies H(s) double H[NUM_IMAGES] = {0}; for (int s = 0; s < NUM_IMAGES; s++) { // TODO: compute co-occurrence probability matrix for image B(s) // TODO: convert P to 1-D array for (int i = 0; i < 4; i++) { double p = /* TODO: get i-th element of P 1-D array */; if (p > 0) { H[s] -= p * log2(p); } }
  • 4. } // Compute similarity measures rho(s) double rho[NUM_IMAGES] = {0}; double max_H = *max_element(H, H + NUM_IMAGES); for (int s = 0; s < NUM_IMAGES; s++) { rho[s] = 1 - H[s] / max_H; } // Find index s_max of image B(s) that is most similar to reference image A double max_rho = -1; int s_max = -1; for (int s = 0; s < NUM_IMAGES; s++) { if (rho[s] > max_rho) { max_rho = rho[s]; s_max = s; } } // Output results cout << "Co-occurrence probability matrix for a sample image from the database:" << endl; // TODO: output P for a sample image cout << "Co-occurrence entropies for the database images:" << endl; for (int s = 0; s < NUM_IMAGES; s++) { cout << "H(" << s << ") = " << H[s] << endl; } cout << "Similarity measures for the reference image with the database images:" << endl Each image consists of 6 rows. Each row has 6 pixels {0,1}. See example on sheet 2