Professional Documents
Culture Documents
BDU - Document - Dominant Color in An Image Using K
BDU - Document - Dominant Color in An Image Using K
NO
i) Acknowledgement
ii) Certificate
Abstract
2 Data Dictionary 13
3 Logical Development 18
4 Program Design 21
5 Testing 24
6 Conclusion 26
7 References 27
8 Appendix 30
i) Source Code
ii) O/P Screenshots
ABSTRACT
Finding most dominant color in an image using the K-Means algorithm leverages machine
learning techniques to extract fundamental color information from digital photographs.
Employing the K-means clustering methodology, this project identifies the most prominent
colors in an image by grouping pixels with similar color values. The main goal is to
automate color extraction so that it may be used more effectively for tasks like object
recognition, image classification, and creating visual content. Traditional color analysis
techniques often focus on extracting the average color of an image, which may not accurately
represent the diverse color distribution within the image. This can lead to inaccurate results
in applications where understanding the dominant colors and their proportions is crucial. So,
this project aims to train a model to predict dominant color clusters in an image using K-
means clustering and provide insights into color proportions. Overall, the project aims to
create a comprehensive framework for color dominance analysis in images, contributing to a
broader understanding of image processing and unsupervised learning techniques.
CHAPTER-1
1.1 INTRODUCTION
"Finding Most Dominant Color in an Image Using K-Means Algorithm, “a research project,
explores the fields of image processing and machine learning to present a method for
obtaining basic color information from digital photos. The study groups pixels with similar
color values to identify the most prevalent colors in an image using the K-Means clustering
algorithm. This project has significant consequences for a variety of fields, including graphic
design, image processing, and text analysis. The main goal is to automate color extraction so
that it may be used more effectively for tasks like object recognition, image classification,
and creating visual content. This study highlights how machine learning can simplify image
processing processes, opening up a promising path for the advancement of numerous visual-
based applications.
In digital image processing, understanding the color composition of an image is often crucial
for various applications like image segmentation, content-based image retrieval, and color-
based object detection. One fundamental task in this domain is to identify the dominant
colors present in an image.
One effective method to achieve this is through the application of the k-means clustering
algorithm. K-means clustering is a popular unsupervised learning technique used to partition
data into clusters based on similarity. In the context of image processing, this algorithm can
be employed to group pixels into clusters based on their color similarity, allowing us to
identify the most prevalent colors within the image.
The process typically involves converting the image into a suitable numerical representation,
applying the k-means algorithm to partition the color space into clusters, and then analyzing
the resulting clusters to extract the dominant colors.
In this document, we will explore the steps involved in finding dominant colors in an image
using the k-means clustering algorithm. We will provide a step-by-step guide along with
code examples in Python using popular libraries such as OpenCV and scikit-learn.
1
By the end of this document, you will have a clear understanding of how to
programmatically extract the dominant colors from an image, enabling you to incorporate
this technique into your own image processing projects with ease.
K-Means Clustering is an unsupervised learning algorithm that is used to solve the clustering
problems in machine learning or data science. In this topic, we will learn what is K-means
clustering algorithm, how the algorithm works, along with the Python implementation of k-
means clustering.
It allows us to cluster the data into different groups and a convenient way to discover the
categories of groups in the unlabeled dataset on its own without the need for any training.
It is a centroid-based algorithm, where each cluster is associated with a centroid. The main
aim of this algorithm is to minimize the sum of distances between the data point and their
corresponding clusters.
The algorithm takes the unlabeled dataset as input, divides the dataset into k-number of
clusters, and repeats the process until it does not find the best clusters. The value of k should
be predetermined in this algorithm.
o Determines the best value for K center points or centroids by an iterative process.
o Assigns each data point to its closest k-center. Those data points which are near to the
particular k-center, create a cluster.
Hence each cluster has datapoints with some commonalities, and it is away from other
clusters.
The below diagram explains the working of the K-means Clustering Algorithm:
2
Figure 1: Working of K-means Clustering Algorithm
Step-2: Select random K points or centroids. (It can be other from the input dataset).
Step-3: Assign each data point to their closest centroid, which will form the predefined K
clusters.
Step-4: Calculate the variance and place a new centroid of each cluster.
Step-5: Repeat the third steps, which means reassign each datapoint to the new closest
centroid of each cluster.
Basically, k-means is a clustering algorithm used in Machine Learning where a set of data
points are to be categorized to ‘k’ groups. It works on simple distance calculation.
3
1. At random select ‘k’ points not necessarily from the dataset.
4. Reassign the data points to the new closest cluster. If any reassignment took
place go to step 3 else the model is ready.
As an image is made of three channels: Red, Green and Blue we can think of each
pixel as a point (x=Red, y=Green, z=Blue) in 3D space and so can apply k-means
clustering algorithm on the same.
After processing each pixel with the algorithm cluster centroids would be the
required dominant colors.
We are going to use this image (dimension - 100 x 100)
import cv2
#read image
4
img = cv2.imread('colors.jpg')
array r, g, b = cv2.split(img)
r = r.flatten()
g = g.flatten()
b = b.flatten()
#plotting
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(r, g, b)
plt.show()
5
Figure 3: 3D plot of “colors.jpg” using x=red, y=green, z=blue
From the plot one can easily see that the data points are forming groups - some places in a
graph are more dense, which we can think as different colors’ dominance on the image. We
will try to achieve these clusters through k-means clustering.
6
Figure 4: clusters in plot
7
Figure 5: Cluster visualization
8
1.4 EXISTING SYSTEM
The project, " Finding the Most Dominant Color in an Image using K-Means Algorithm
Based on Machine Learning," explores the application of K-Means clustering for identifying
and visualizing dominant colors in images. The literature review outlines key research areas
related to image clustering, color analysis, and visualization techniques.
Jain, A. (2010). Data Clustering: 50 Years Beyond K-Means. Pattern Recognition Letters.
Jain's comprehensive review provides
insights into the evolution of clustering techniques, emphasizing the significance of K-Means
and its variants. Understanding the advancements in clustering algorithms informs the choice
of K-Means in the project.
Cheng, Z., Yang, J., Shi, Y., & Huang, T. (2001). Color Image Segmentation: Advances and
Prospects. Pattern Recognition.
Cheng et al. delve into color image segmentation, discussing various methods for extracting
meaningful information from color images. The review aids in understanding the
complexities of color representation and segmentation, which are fundamental to the project's
objectives.
Huang, K., & Aviyente, S. (2015). K-Means-Based Clustering Approach for Color Image
Segmentation. EURASIP Journal on Image and Video Processing. This study specifically
explores the application of K-Means clustering for color image segmentation. The insights
provided contribute to the rationale behind using K-Means for color dominance analysis in
the project.
Ware, C. (2012). Information Visualization: Perception for Design. Elsevier. Ware's work on
information visualization is crucial for understanding principles that enhance the
interpretability of visual representations. The project benefits from these principles to
effectively communicate dominant colors through graphical outputs.
9
1.4.5. Evaluation of Unsupervised Learning Results
The existing literature provides a strong foundation for image clustering, color analysis, and
visualization techniques.
Overall, the project integrates insights from diverse literature sources to create a
comprehensive framework for color dominance analysis in images, contributing to the
broader understanding of image processing and unsupervised learning techniques.
He, Wang, and Li proposed a novel approach for dominant color extraction using k-means
clustering in their paper titled "Color Image Quantization Based on K-means Clustering with
Markov Random Field Model." They introduced a Markov random field model to refine the
clustering results and improve color quantization accuracy.
Their method demonstrated superior performance in terms of color fidelity and visual quality
compared to traditional k-means clustering techniques, particularly in scenarios with
complex color distributions or texture patterns.
Singh and Ahuja investigated the application of k-means clustering for dominant color
extraction in their paper "Color Clustering for Image Segmentation." They proposed an
adaptive k-means algorithm capable of automatically determining the optimal number of
clusters based on image characteristics.
Their adaptive approach addressed the challenge of selecting the appropriate number of
clusters, which is critical for accurate color segmentation and dominant color extraction in
diverse image datasets.
10
3. S. Zeng and X. Chen:
Zeng and Chen contributed to the field of dominant color extraction with their paper "A
Novel Image Quantization Algorithm Using K-means Clustering with Density Peaks." They
introduced a density peaks-based initialization method for k-means clustering to improve
convergence speed and clustering quality.
The proposed system aims to automate color extraction in images using the K-Means
clustering algorithm. By identifying dominant color clusters, it provides accurate insights
into color distribution, crucial for tasks like object recognition and image classification. The
system's framework encompasses preprocessing, clustering, and visualization stages, offering
versatility and scalability. Leveraging machine learning techniques, it enhances accuracy and
efficiency in color dominance analysis, contributing to advancements in image processing
and unsupervised learning. elobarate into few more lines
11
1.6 PROBLEM STATEMENT
Traditional color analysis techniques often focus on extracting the average color of an image,
which may not accurately represent the diverse color distribution within the image. This can
lead to inaccurate results in applications where understanding the dominant colors and their
proportions is crucial. So this project aims to train a model to predict dominant color clusters
in an image using K means clustering, and provide insights into color proportions.
1) Data Preparation: Collect a dataset of images with labeled dominant color clusters.
Preprocess the images to a consistent size.
2) Feature Extraction: Extract features from images (possibly using color histograms, K-
means cluster centers, etc.).
3) Model Training: Train a machine learning model (e.g., a classifier) on the labeled dataset
to predict the dominant color clusters.
4) Evaluation: Evaluate the model's performance on a test set using appropriate metrics
(accuracy, precision, recall).
5) Application: Integrate the trained model into an application for automatic color
quantization.
1.7 OBJECTIVE
This objective statement outlines the goals and milestones for implementing the k-means
clustering algorithm for extracting dominant colors from images, emphasizing the
importance of image preprocessing, clustering, color extraction, visualization, performance
evaluation, and documentation.
12
CHAPTER-2
DATA DICTIONARY
The k-means clustering algorithm is an unsupervised machine learning technique that seeks
to group similar data into distinct clusters to uncover patterns in the data that may not be
apparent to the naked eye.
It is possibly the most widely known algorithm for data clustering and is implemented in the
OpenCV library.
2.1.1. OpenCV
The necessary libraries are imported, including OpenCV (cv2), NumPy (np), Matplotlib
(plt), imutils, and KMeans from scikit-learn.
Parameters Setup: The number of clusters (clusters) is set, which determines the number of
dominant colors to be extracted from the image.
Read and Resize Image: The script reads an image using OpenCV's imread function and then
resizes it to a fixed height of 200 pixels using the imutils.resize function. Resizing helps
speed up the processing, and a fixed height is chosen to maintain the aspect ratio of the
original image.
Flatten Image: The image is flattened into a 2D array using NumPy's reshape function. This
step converts the 3D image array (height × width × channels) into a 2D array (pixels ×
channels), where each row represents a pixel and each column represents a color channel (R,
G, B).
Apply K-Means Clustering: K-means clustering is applied to the flattened image array to
group similar colors into clusters number of clusters. Each cluster center represents a
dominant color in the image. Calculate Dominant Colors and Percentages: The cluster centers
(dominant colors) and their corresponding percentages of pixels in the image are calculated.
This information is stored in the p_and_c variable as tuples of (percentage, color).
13
2.1.2 Visualize Dominant Colors:
Matplotlib is used to visualize the dominant colors.
Two plots are created:
The first plot shows individual color blocks representing each dominant color along
with their percentages.
The second plot is a horizontal bar chart showing the proportions of colors in the
image. Each color block's width represents its proportion in the image.
14
2.1.3. Clustering as an Unsupervised Machine Learning Task
Cluster analysis is an unsupervised learning technique. It involves automatically grouping
data into distinct groups (or clusters), where the data within each cluster are similar but
different from those in the other clusters. It aims to uncover patterns in the data that may not
be apparent before clustering. There are many different clustering algorithms, as explained
in this tutorial, with k-means clustering being one of the most widely known. The k-means
clustering algorithm takes unlabelled data points. It seeks to assign them to k clusters, where
each data point belongs to the cluster with the nearest cluster center, and the center of each
cluster is taken as the mean of the data points that belong to it. The algorithm requires that
the user provide the value of k as an input; hence, this value needs to be known a priori or
tuned according to the data.
The code above should generate the following plot of data points:
15
Figure 6: Scatter Plot of Dataset Consisting of 5 Gaussian
Clusters
If we look at this plot, we may already be able to visually distinguish one cluster from
another, which means that this should be a sufficiently straightforward task for the k-means
clustering algorithm.
In OpenCV, the k-means algorithm is not part of the ml module but can be called directly.
To be able to use it, we need to specify values for its input arguments as follows:
defining the desired accuracy and the maximum number of iterations, respectively,
The number of attempts, denoting the number of times the algorithm will be executed
16
2.1.5. The k-means clustering algorithm in OpenCV returns:
The compactness of each cluster, computed as the sum of the squared distance of each data
point to its corresponding cluster center. A smaller compactness value indicates that the data
points are distributed closer to their corresponding cluster center and, hence, the cluster is
more compact.
The predicted cluster labels y_pred, associate each input data point with its corresponding
cluster.
Let’s now apply the k-means clustering algorithm to the dataset generated earlier. Note that
we are type-casting the input data to float32, as expected by the kmeans() function in
OpenCV:
# Plot the data clusters, each having a different color, together with the corresponding cluster
centers
show()
17
CHAPTER-3
LOGICAL DEVELOPMENT
Identify the task of extracting dominant colors from an image. Recognize that this task
involves identifying clusters of similar colors in the image.
Study existing methods and algorithms for color extraction, including clustering algorithms
like K-Means. Understand machine learning concepts related to clustering, such as
unsupervised learning, where the algorithm learns patterns in the data without explicit labels.
Specify requirements such as input image format (e.g., JPEG, PNG), desired output format
(e.g., color palette, visualization), and any constraints or preferences regarding color
granularity.
Image Acquisition: Obtain the target image using libraries like OpenCV, ensuring
compatibility with subsequent processing steps.
Feature Extraction: Convert the image data into a format suitable for analysis. For color
extraction, this typically involves representing each pixel as a feature vector containing color
information (e.g., RGB values).
3.6 NORMALIZATION:
Normalize the feature vectors to ensure that each feature contributes equally to the clustering
process, especially if different color channels have different ranges.
18
3.7 CLUSTERING:
K-Means Clustering: Apply the K-Means algorithm to the feature vectors. Choose the
number of clusters (k) based on the desired number of dominant colors in the image.
19
3.10 DATA FLOW DIAGRAM
Image as Input
Converting the raw data from the image to a raw dataframe in “long” format
The Data obtained is now used for clustering. Set an initial seed
Apply the K-Means Algorithm. Obtain the color from clustered data
By using the raw colors extracted m image. Calculate the Crop Stage
fro
If image has
expected color as Starting
Crop color
20
CHAPTER-4
PROGRAM DESIGN
The K-means clustering implementation is a method through which a set of data points can
be partitioned into several disjoint subsets where the points in each subset are deemed to be
‘close’ to each other (according to some metric). A common metric, at least when the points
can be geometrically represented is the standard Euclidean distance function. The ‘k’ just
refers to the number of subsets desired in the final output. It turns out that this approach is
exactly what we need to divide our image into a set of colours. Implementation of the
original K-means clustering is very straightforward method. Suppose reduction to K colors;
first, palette is established by selecting K random pixels from the input image. In second
step, the K-means algorithm is used to modify this palette. Third, the input image is
converted to output image.
By using k-mean clustering, it is possible to detect dominant colors in an image. After going
through sequence of web snippets and code playing, it is noticed excellent results using k-
means colour clustering algorithm. The k-mean clustering can be implemented
2. For every data point, calculate distance from each of the ‘k’ clusters and assign it to
least distant cluster.
3. Next every assignment recalculate the cluster centroid by averaging the distances
of all the associated points.
4. In the further step, there is the process of distance calculation from each ‘K’ values
5. After distance calculation, form the specific clusters, calculate the mean value for
each clusters which shows the particular colour
21
6. If the data value is higher for a particular cluster, compute the mean value of that
cluster. If the mean is greater than some threshold, split the cluster in half. Continue
this process until all intensities are done, and we will have a more efficient clustering
data points.
4.2 METHODOLOGY
1) Image Acquisition: Obtain the target image for color dominance analysis. The
image should be in a format compatible with the OpenCV library (commonly JPEG or
PNG).
2) Image Resizing: Use the imutils library to resize the image to a specified height
while maintaining the aspect ratio. This step ensures uniformity in the analysis and
reduces computational complexity.
3) Flatten Image: Flatten the resized image to create a feature vector. Reshape the
image to a 2D array where each row represents a pixel and each column represents the
RGB values
22
5) Dominant Colors Extraction: Retrieve the cluster centers, which represent the
dominant colors in the image. These centers are the average color values of pixels
assigned to each cluster during the clustering process.
8) Image Overlay: Resize the original image to a desired display size, maintaining the
aspect ratio. Create a copy of the resized image and overlay it with a white rectangle
to display information about the most dominant colors.
9) Final Visualization: Combine the original image with the overlaid information,
creating a final visualization that highlights the dominant colors. Add text annotations
to convey relevant details about the color analysis.
10) Display and Save Results: Display the final visualization using OpenCV.
Optionally, save the resulting image to a file (e.g., 'output.jpg') for future reference.
23
CHAPTER-5
TESTING
The outcome of the K-means algorithm consists of a set of centroids, one for each K cluster.
Those coordinates are a list of K RGB triplets of dominant colors, which represent the main
colors found in the input digital image. The second stage seeks the correct identification of
the color chart patches from the dominant colors from the K-means algorithm. The dominant
colors extracted in the RGB color space can be easily transformed to CIE XYZ tristimulus
values and CIELAB coordinates as required for subsequent processing. With the CIELAB
coordinates the color differences are computed between each dominant color and the whole
set of color chips. It is then possible to identify the nearest patches to each dominant color
found in the image by looking for the lowest ∆E∗ab.
For the identification of color patches, four different approaches are tested after varying the
input data and colorimetric criteria:
(1) using the n nearest patches found in the whole image (NN),
(2)removing the color chart from the scene and identifying the n nearest patches (RC), (3)
using a set of samples corresponding to pigment and support classes and creating a new,
joined synthetic image(JS), and
(4) using the same sample set used in (3), but computing each class separately (SS). Note
that while in the first method we do not specify any colorimetric criteria, in the remaining
cases we search for the nearest patches to each dominant color with ∆E∗ab color differences
less than 10 CIELAB units(maximum value allowed in cultural heritage guidelines).
Although the use of the nearest patches extracted from dominant colors using K-means offer
accurate colorimetric results, it does not always imply a proper output characterized image,
that is, an image with true colorimetric sense. Our experience shows that a set of minimum
fixed patches should be included in order to obtain accurate and colorimetrically sound
characterized images, including the primary additive colors and the basic grayscale chips.
24
5.2 K Number of Clusters
The first issue to consider is the proper determination of the K number of clusters. That
number can be determined by simple heuristics, for instance by testing several values of K
and taking some convenient value, or with specific data mining tools such as the Elbow or
the Silhouette graphic methods. A preliminary experiment was conducted under the worst-
case scenario; that is, using the whole image as input data which gives some sort of upper
bound in terms of computation time. The results about the running time required for
computing K- means clustering are displayed in Table 1. According to those results, K = 24
seems to be an acceptable number of clusters
Evaluation Metrics
Prediction Score:
25
CHAPTER-6
CONCLUSION
26
CHAPTER-7
REFERENCES
1. Sesana, E.; Gagnon, A.S.; Bertolin, C.; Hughes, J. Adapting cultural heritage to climate
305. [CrossRef]
2. Cerra, D.; Plank, S.; Lysandrou, V.; Tian, J. Cultural Heritage Sites in Danger—Towards
3. Barrile, V.; Fotia, A.; Bilotta, G.; De Carlo, D. Integration of geomatics methodologies and
creation of acultural heritage app using augmented reality. Virtual Archaeol. Rev. 2019,10,
40–51. [CrossRef]
4. Lerma, J.L.; Navarro, S.; Cabrelles, M.; Villaverde, V. Terrestrial laser scanning and close
6. Pan, Y.; Dong, Y.; Wang, D.; Chen, A.; Ye, Z. Three-dimensional reconstruction of
structural surface model ofheritage bridges using UAV-based photogrammetric point clouds.
7. Tang, P.; Chen, F.; Zhu, X.; Zhou, W. Monitoring cultural heritage sites with advanced
multi-temporal InSARtechnique: The case study of the Summer Palace. Remote Sens.
27
8. Padín, J.; Martín, A.; Anquela, A.B. Archaeological microgravimetric prospection inside
9. Rogerio-Candelera, M.A. Digital image analysis based study, recording, and protection of
painted rock art.Some Iberian experiences. Digit. Appl. Archaeol. Cult. Herit. 2015,2, 68–78.
[CrossRef]
10. Federica, M.; Di Giulio, R.; Piaia, E.; Medici, M.; Ferrari, F. Enhancing Heritage fruition
through 3D semanticmodelling and digital tools: the INCEPTION project. IOP Conf. Ser.
11. Cabrelles, M.; Blanco-Pons, S.; Carrión-Ruiz, B.; Lerma, J.L. From Multispectral 3D
Perspectives on Culture Change in the Middle East;Levy, T.E., Jones, I.W.N., Eds.; Springer:
12. Ippoliti, E.; Calvano, M. Enhancing the Cultural Heritage Between Visual Technologies
13. del Hoyo-Meléndez, J.M.; Carrión-Ruiz, B.; Riutort-Mayol, G.; Lerma, J.L. Lightfastness
assessment ofLevantine rock art by means of microfading spectrometry. Color Res. Appl.
15. Boochs, F.; Bentkowska-Kafel, A.; Degrigny, C.; Karaszewski, M.; Karmacharya, A.;
Kato, Z.; Picollo, M.;Sitnik, R.; Trémeau, A.; Tsiafaki, D. Colour and Space in Cultural
28
Heritage: Key Questions in 3D OpticalDocumentation of Material Culture for Conservation,
EuroMed 2014, Limassol, Cyprus, 3–8 November 2014; Springer: Berlin, Germany; Volume
8740,pp. 11–24
29
CHAPTER-8
APPENDIX
app.py
import matplotlib
matplotlib.use('Agg')
app = Flask(_name_)
UPLOAD_FOLDER = 'most-dominant-color/static/uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
30
percentages = (np.unique(kmeans.labels_, return_counts=True)[1]) / flat_img.sh…
[3:12 PM, 4/27/2024] Sathyanarayana: most_dominantcolor.pyimport cv2
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import imutils
img = cv2.imread(r'most-dominant-color/static/uploads/images.jpeg')
org_img = img.copy()
print('Org image shape --> ',img.shape)
# rows = 200
# cols = int((img.shape[0]/img.shape[1])*rows)
img = imutils.resize(img,height=200)
# img = cv2.resize(img,dsize=(rows,cols),interpolation=cv2.INTER_LINEAR)
print('After resizing shape --> ',img.shape)
flat_img = np.reshape(img,(-1,3))
print('After Flattening shape --> ',flat_img.shape)
kmeans = KMeans(n_clusters=clusters,random_state=0)
kmeans.fit(flat_img)
dominant_colors = np.array(kmeans.cluster_centers_,dtype='uint')
percentages = (np.uniqu…
31
[3:13 PM, 4/27/2024] Sathyanarayana: import
cv2 import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import imutils
# Number of
clusters clusters = 5
32
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dominant Color Extractor </title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-
JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous">
<link rel="stylesheet" href="../static/stylesheets/style.css">
<link rel="stylesheet" href="../static/stylesheets/fullpage.min.css">
<link
href="https://fonts.googleapis.com/css2?family=Lato&family=Open+Sans+Condensed:wght
@700&display=swap"
rel="stylesheet">
<style>
body {
width: 100vw;
height: 100vh;
}
*{
box-shadow: none !important;
}
h1 {
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 700;
}
h4 {
font-family: 'Lato', sans-serif;
}
33
h1#title1 {
font-size: 75px;
}
h4#subtitle1 {
font-size: 30px;
}
h1#title2 {
font-size: 55px;
margin-bottom: 20px;
color: white;
}
h4#subtitle2 {
font-size: 22px;
text-align: justify;
color: white;
}
.image-container {
width: 300px;
min-height: 100px;
border: 2px solid
#dddddd; margin-bottom:
15px; display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
color: #cccccc;
}
.image-preview__image {
display: none;
34
width: 100%;
}
#linkedin,
#github,
#submit {
margin-top: 10px;
background-color: transparent;
border-radius: 15px;
}
#linkedin:hover,
#github:hover,
#submit:hover {
color: white;
background-color: black;
}
.interactiveDiv {
background-color: rgba(255, 255, 255, 0.452);
padding: 20px;
border-radius: 15px;
}
#caption {
background-color: white;
}
}
35
#textbox1,
#textbox2,
#textbox3 {
animation: fadeInAnimation ease
3s; animation-fill-mode: forwards;
animation-play-state: paused;
}
@keyframes fadeInAnimation {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div id="fullpage">
<div class="section">
<div class="container" id="textbox1">
<div class="row">
<div class="col-lg-6">
<h1 id="title1">Dominant Color <br> Extraction</h1>
<h4 id="subtitle1">For Agriculture Purpose</h4>
</div>
<div class="d-none d-lg-block col-lg-6">
<img src="../static/images/s1.svg" width="450" class="img-fluid">
</div>
</div>
</div>
36
</div>
<div class="section">
<div class="container" id="textbox2">
<div class="row">
<div class="d-none d-lg-block col-lg-7">
<center>
<img src="../static/images/s2.svg" width="600" style="padding-top: 50px"
class="img-fluid">
</center>
</div>
<div class="col-lg-5 col-12">
<!-- Display "Starting stage" or "Ending stage" -->
{% if starting_stage %}
<p>Starting stage</p>
{% endif %}
{% if ending_stage %}
<p>Ending stage</p>
{% endif %}
</div>
</div>
<div style="margin-left: 700px; margin-bottom: 300px;">
<h1 style="color:aliceblue">Upload an Image</h1>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="file" accept="image/*">
<button type="submit" >Upload</button>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="section">
37
<center>
<div class="row">
<div class="col-md-5 col-12 {{'offset-md-3 pl-md-5' if not output}}">
<div class="ml-md-5 interactiveDiv">
<h5 class="pb-1">Interactive Model</h5>
<div class="image-preview mb-3" id="imagePreview">
<img alt="Image Preview" class="image-preview__image img-fluid"
style="width: auto; max-height: 60vh;">
</div>
</div>
<ul>
{% for p, c in p_and_c %}
<p style="color:rgb(0, 4, 75)">Color: {{ c }} - Percentage: {{ '%.2f' % (p
* 100) }}%</p>
{% endfor %}
</ul>
<img src='../static/uploads/color_proportions.png' alt="color proportion"
height="200px" style=" margin-left: 280px; margin-top:0;">
{% endif %}
</div>
</center>
</div>
<div class="section">
<div class="container" id="textbox3">
38
<div class="row">
<div class="col-lg-6 col-12 mb-4 mb-md-0">
<h1>ABOUT</h1>
<h4 style="text-align: justify;">This project is made by Neelanjan Manna, a
fellow Machine
Learning and Data Science enthusiast currently enrolled in Bachelor of
Technology course at
KIIT University.</h4>
<a href="https://linkedin.com/in/neelanjan00/" target="blank"><button
class="btn" id="linkedin"
style="border: 1px solid black;">My Linkedin</button></a>
<a href="https://github.com/neelanjan00/" target="blank"><button class="btn
ml-3" id="github"
style="border: 1px solid black;">My Github</button></a>
<h1 class="mt-5">REFERENCES</h1>
<h4>
<a href="https://ieeexplore.ieee.org/abstract/document/8953774/"
style="color: black;">1.
ManTra-Net: Manipulation Tracing Network for Detection and
Localization of Image
Forgeries With Anomalous Features</a><br><br>
<a href="https://towardsdatascience.com/image-forgery-detection-
2ee6f1a65442"
image manipulation</a><br>
</h4>
</div>
<div class="d-none d-lg-block col-lg-6">
<img src="../static/images/s3.svg" width="500" class="pt-5 img-fluid">
</div>
</div>
</div>
</div>
39
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-
J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="../static/scripts/fullpage.min.js"></script>
<script>
var fullpage_api = new fullpage('#fullpage', {
autoScrolling: true,
scrollHorizontally: true,
verticallyCentered: true,
responsiveWidth: 767,
anchors: ['section1', 'section2', 'section3', 'section4'],
$(".custom-file-input").on("change", function () {
var fileName = $(this).val().split("\\").pop();
$(this).siblings(".custom-file-label").addClass("selected").html(fileName);
});
inpFile.addEventListener('change', function () {
40
const file = this.files[0];
if (file) {
const reader = new FileReader();
previewImage.style.display = "block";
reader.addEventListener("load", function () {
previewImage.setAttribute("src", this.result);
});
reader.readAsDataURL(file);
}
})
</script>
{% if output %}
<script>
fullpage_api.silentMoveTo(3);
</script>
{% endif %}
</body>
</html>
41
8.2 SCREEN SHOTS
42
Input image
43
44