Apostolos Fanakis
6 years ago
19 changed files with 855 additions and 89 deletions
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 6.3 KiB |
@ -0,0 +1,55 @@ |
|||
\subsection{Αναδρομικός normalized cuts} |
|||
|
|||
Η εκδοχή της αναδρομικής εκτέλεσης παρουσιάζεται στο script \texttt{demo3c}. Το script εκτελεί μία σειρά από δύο πειράματα κατά τα οποία γίνεται κατάτμηση δύο δοσμένων εικόνων (``\texttt{d2a}'' και ``\texttt{d2b}'') σε ομάδες (clusters) διαδοχικά. Τα αποτελέσματα φαίνονται και σχολιάζονται στη συνέχεια. |
|||
|
|||
Στο πρώτο μέρος του script εκτελείται το πείραμα για την πρώτη εικόνα που δίνεται (``\texttt{d2a}''). Το αποτέλεσμα της κατάτμησης φαίνεται παρακάτω. |
|||
|
|||
\begin{multicols}{2} |
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/demo3c_e1_f1.pdf_tex}} |
|||
} |
|||
\caption{Αρχική εικόνα (``\texttt{d2a}'')} |
|||
\end{figure} |
|||
|
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/demo3c_e1_f2.pdf_tex}} |
|||
} |
|||
\caption{Κατάτμηση πρώτης εικόνας (``\texttt{d2a}''), τυχαίος χωματισμός των ομάδων} |
|||
\end{figure} |
|||
\end{multicols} |
|||
|
|||
Σε αυτή τη περίπτωση ο αλγόριθμος κάνει τη βέλτιστη ομαδοποίηση, σταματώντας στις τρεις ομάδες και αντιστοιχίζοντας μία ομάδα σε κάθε χρώμα της αρχικής εικόνας. |
|||
|
|||
Στο δεύτερο μέρος του script εκτελείται το πείραμα για την δεύτερη εικόνα που δίνεται (``\texttt{d2b}''). Το αποτέλεσμα της κατάτμησης φαίνεται παρακάτω. |
|||
|
|||
\begin{multicols}{2} |
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/demo3c_e2_f1.pdf_tex}} |
|||
} |
|||
\caption{Αρχική εικόνα (``\texttt{d2b}'')} |
|||
\end{figure} |
|||
|
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/demo3c_e2_f3.pdf_tex}} |
|||
} |
|||
\caption{Κατάτμηση πρώτης εικόνας (``\texttt{d2b}''), τυχαίος χωματισμός των ομάδων} |
|||
\end{figure} |
|||
\end{multicols} |
|||
|
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/demo3c_e2_f2.pdf_tex}} |
|||
} |
|||
\caption{Κατάτμηση πρώτης εικόνας (``\texttt{d2b}''), χρωματικός διάμεσος} |
|||
\end{figure} |
|||
|
|||
Στη δεύτερη εικόνα ο αλγόριθμος χωρίζει σε τρεις ομάδες με πολύ ικανοποιητικά αποτελέσματα. |
@ -1,16 +1,39 @@ |
|||
\section{Εκτέλεση και αποτελέσματα} |
|||
|
|||
% Παρακάτω παρατίθενται ενδεικτικά οι χρόνοι εκτέλεσης των βασικών συναρτήσεων για επιλεγμένες διαστάσεις τελικής εικόνας 960Χ1280 καθώς: |
|||
Από τη προηγούμενη ανάλυση βγαίνει το συμπέρασμα ότι η αναδρομική εκδοχή του normalized cuts αλγόριθμου δίνει τα βέλτιστα αποτελέσματα. Για την περαιτέρω επίδειξη της ποιότητας του αλγορίθμου, η αναδρομική εκδοχή του δοκιμάστηκε σε πραγματικές εικόνες. Τα αποτελέσματα φαίνονται παρακάτω. |
|||
|
|||
% \begin{table}[H] |
|||
% \centering |
|||
% \begin{tabular}{l l} \toprule |
|||
% Συνάρτηση & Χρόνος (seconds) \\ \midrule |
|||
% \texttt{bayer2rgb} (``nearest'') & 0.164 \\ |
|||
% \texttt{bayer2rgb} (``linear'') & 0.484 \\ |
|||
% \texttt{imagequant} & 0.0315 \\ |
|||
% \texttt{imagedequant} & 0.024 \\ |
|||
% \texttt{saveasppm} & 0.208 \\ \bottomrule |
|||
% \end{tabular} |
|||
% \caption{Χρόνοι βασικών συναρτήσεων} |
|||
% \end{table} |
|||
\begin{multicols}{2} |
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/exp_1_o.pdf_tex}} |
|||
} |
|||
\caption{Αρχική εικόνα} |
|||
\end{figure} |
|||
|
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/exp_1_c.pdf_tex}} |
|||
} |
|||
\caption{Κατάτμηση εικόνας, χρωματικός διάμεσος} |
|||
\end{figure} |
|||
\end{multicols} |
|||
|
|||
\begin{multicols}{2} |
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/exp_2_o.pdf_tex}} |
|||
} |
|||
\caption{Αρχική εικόνα} |
|||
\end{figure} |
|||
|
|||
\begin{figure}[H] |
|||
\centering |
|||
\resizebox{.5\textwidth}{!}{ |
|||
\colorbox{shadecolor}{\input{res/exp_2_c.pdf_tex}} |
|||
} |
|||
\caption{Κατάτμηση εικόνας, χρωματικός διάμεσος} |
|||
\end{figure} |
|||
\end{multicols} |
|||
|
@ -0,0 +1,58 @@ |
|||
%% Creator: Inkscape inkscape 0.92.3, www.inkscape.org |
|||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 |
|||
%% Accompanies image file 'exp_1_c.pdf' (pdf, eps, ps) |
|||
%% |
|||
%% To include the image in your LaTeX document, write |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics{<filename>.pdf} |
|||
%% To scale the image, write |
|||
%% \def\svgwidth{<desired width>} |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics[width=<desired width>]{<filename>.pdf} |
|||
%% |
|||
%% Images with a different path to the parent latex file can |
|||
%% be accessed with the `import' package (which may need to be |
|||
%% installed) using |
|||
%% \usepackage{import} |
|||
%% in the preamble, and then including the image with |
|||
%% \import{<path to file>}{<filename>.pdf_tex} |
|||
%% Alternatively, one can specify |
|||
%% \graphicspath{{<path to file>/}} |
|||
%% |
|||
%% For more information, please see info/svg-inkscape on CTAN: |
|||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape |
|||
%% |
|||
\begingroup% |
|||
\makeatletter% |
|||
\providecommand\color[2][]{% |
|||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% |
|||
\renewcommand\color[2][]{}% |
|||
}% |
|||
\providecommand\transparent[1]{% |
|||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% |
|||
\renewcommand\transparent[1]{}% |
|||
}% |
|||
\providecommand\rotatebox[2]{#2}% |
|||
\newcommand*\fsize{\dimexpr\f@size pt\relax}% |
|||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}% |
|||
\ifx\svgwidth\undefined% |
|||
\setlength{\unitlength}{67.49999915bp}% |
|||
\ifx\svgscale\undefined% |
|||
\relax% |
|||
\else% |
|||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}% |
|||
\fi% |
|||
\else% |
|||
\setlength{\unitlength}{\svgwidth}% |
|||
\fi% |
|||
\global\let\svgwidth\undefined% |
|||
\global\let\svgscale\undefined% |
|||
\makeatother% |
|||
\begin{picture}(1,1)% |
|||
\lineheight{1}% |
|||
\setlength\tabcolsep{0pt}% |
|||
\put(0,0){\includegraphics[width=\unitlength,page=1]{exp_1_c.pdf}}% |
|||
\end{picture}% |
|||
\endgroup% |
After Width: | Height: | Size: 4.5 KiB |
@ -0,0 +1,58 @@ |
|||
%% Creator: Inkscape inkscape 0.92.3, www.inkscape.org |
|||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 |
|||
%% Accompanies image file 'exp_1_o.pdf' (pdf, eps, ps) |
|||
%% |
|||
%% To include the image in your LaTeX document, write |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics{<filename>.pdf} |
|||
%% To scale the image, write |
|||
%% \def\svgwidth{<desired width>} |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics[width=<desired width>]{<filename>.pdf} |
|||
%% |
|||
%% Images with a different path to the parent latex file can |
|||
%% be accessed with the `import' package (which may need to be |
|||
%% installed) using |
|||
%% \usepackage{import} |
|||
%% in the preamble, and then including the image with |
|||
%% \import{<path to file>}{<filename>.pdf_tex} |
|||
%% Alternatively, one can specify |
|||
%% \graphicspath{{<path to file>/}} |
|||
%% |
|||
%% For more information, please see info/svg-inkscape on CTAN: |
|||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape |
|||
%% |
|||
\begingroup% |
|||
\makeatletter% |
|||
\providecommand\color[2][]{% |
|||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% |
|||
\renewcommand\color[2][]{}% |
|||
}% |
|||
\providecommand\transparent[1]{% |
|||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% |
|||
\renewcommand\transparent[1]{}% |
|||
}% |
|||
\providecommand\rotatebox[2]{#2}% |
|||
\newcommand*\fsize{\dimexpr\f@size pt\relax}% |
|||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}% |
|||
\ifx\svgwidth\undefined% |
|||
\setlength{\unitlength}{67.49999915bp}% |
|||
\ifx\svgscale\undefined% |
|||
\relax% |
|||
\else% |
|||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}% |
|||
\fi% |
|||
\else% |
|||
\setlength{\unitlength}{\svgwidth}% |
|||
\fi% |
|||
\global\let\svgwidth\undefined% |
|||
\global\let\svgscale\undefined% |
|||
\makeatother% |
|||
\begin{picture}(1,1)% |
|||
\lineheight{1}% |
|||
\setlength\tabcolsep{0pt}% |
|||
\put(0,0){\includegraphics[width=\unitlength,page=1]{exp_1_o.pdf}}% |
|||
\end{picture}% |
|||
\endgroup% |
After Width: | Height: | Size: 33 KiB |
@ -0,0 +1,58 @@ |
|||
%% Creator: Inkscape inkscape 0.92.3, www.inkscape.org |
|||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 |
|||
%% Accompanies image file 'exp_2_c.pdf' (pdf, eps, ps) |
|||
%% |
|||
%% To include the image in your LaTeX document, write |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics{<filename>.pdf} |
|||
%% To scale the image, write |
|||
%% \def\svgwidth{<desired width>} |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics[width=<desired width>]{<filename>.pdf} |
|||
%% |
|||
%% Images with a different path to the parent latex file can |
|||
%% be accessed with the `import' package (which may need to be |
|||
%% installed) using |
|||
%% \usepackage{import} |
|||
%% in the preamble, and then including the image with |
|||
%% \import{<path to file>}{<filename>.pdf_tex} |
|||
%% Alternatively, one can specify |
|||
%% \graphicspath{{<path to file>/}} |
|||
%% |
|||
%% For more information, please see info/svg-inkscape on CTAN: |
|||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape |
|||
%% |
|||
\begingroup% |
|||
\makeatletter% |
|||
\providecommand\color[2][]{% |
|||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% |
|||
\renewcommand\color[2][]{}% |
|||
}% |
|||
\providecommand\transparent[1]{% |
|||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% |
|||
\renewcommand\transparent[1]{}% |
|||
}% |
|||
\providecommand\rotatebox[2]{#2}% |
|||
\newcommand*\fsize{\dimexpr\f@size pt\relax}% |
|||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}% |
|||
\ifx\svgwidth\undefined% |
|||
\setlength{\unitlength}{67.49999915bp}% |
|||
\ifx\svgscale\undefined% |
|||
\relax% |
|||
\else% |
|||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}% |
|||
\fi% |
|||
\else% |
|||
\setlength{\unitlength}{\svgwidth}% |
|||
\fi% |
|||
\global\let\svgwidth\undefined% |
|||
\global\let\svgscale\undefined% |
|||
\makeatother% |
|||
\begin{picture}(1,1)% |
|||
\lineheight{1}% |
|||
\setlength\tabcolsep{0pt}% |
|||
\put(0,0){\includegraphics[width=\unitlength,page=1]{exp_2_c.pdf}}% |
|||
\end{picture}% |
|||
\endgroup% |
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,58 @@ |
|||
%% Creator: Inkscape inkscape 0.92.3, www.inkscape.org |
|||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 |
|||
%% Accompanies image file 'exp_2_o.pdf' (pdf, eps, ps) |
|||
%% |
|||
%% To include the image in your LaTeX document, write |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics{<filename>.pdf} |
|||
%% To scale the image, write |
|||
%% \def\svgwidth{<desired width>} |
|||
%% \input{<filename>.pdf_tex} |
|||
%% instead of |
|||
%% \includegraphics[width=<desired width>]{<filename>.pdf} |
|||
%% |
|||
%% Images with a different path to the parent latex file can |
|||
%% be accessed with the `import' package (which may need to be |
|||
%% installed) using |
|||
%% \usepackage{import} |
|||
%% in the preamble, and then including the image with |
|||
%% \import{<path to file>}{<filename>.pdf_tex} |
|||
%% Alternatively, one can specify |
|||
%% \graphicspath{{<path to file>/}} |
|||
%% |
|||
%% For more information, please see info/svg-inkscape on CTAN: |
|||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape |
|||
%% |
|||
\begingroup% |
|||
\makeatletter% |
|||
\providecommand\color[2][]{% |
|||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% |
|||
\renewcommand\color[2][]{}% |
|||
}% |
|||
\providecommand\transparent[1]{% |
|||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% |
|||
\renewcommand\transparent[1]{}% |
|||
}% |
|||
\providecommand\rotatebox[2]{#2}% |
|||
\newcommand*\fsize{\dimexpr\f@size pt\relax}% |
|||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}% |
|||
\ifx\svgwidth\undefined% |
|||
\setlength{\unitlength}{67.49999915bp}% |
|||
\ifx\svgscale\undefined% |
|||
\relax% |
|||
\else% |
|||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}% |
|||
\fi% |
|||
\else% |
|||
\setlength{\unitlength}{\svgwidth}% |
|||
\fi% |
|||
\global\let\svgwidth\undefined% |
|||
\global\let\svgscale\undefined% |
|||
\makeatother% |
|||
\begin{picture}(1,1)% |
|||
\lineheight{1}% |
|||
\setlength\tabcolsep{0pt}% |
|||
\put(0,0){\includegraphics[width=\unitlength,page=1]{exp_2_o.pdf}}% |
|||
\end{picture}% |
|||
\endgroup% |
After Width: | Height: | Size: 33 KiB |
@ -1,35 +1,15 @@ |
|||
image = imageT; |
|||
k = 3; |
|||
k = 4; |
|||
|
|||
graph = Image2Graph(image); |
|||
%clusters = mySpectralClustering(graph, k); |
|||
clusters = myNCuts(graph, k); |
|||
%clusters = myNCuts(graph, k); |
|||
clusters = recursiveNCuts(graph); |
|||
|
|||
clusters = reshape(clusters, size(image, 1), []); |
|||
|
|||
redChannel = image(:, :, 1); |
|||
greenChannel = image(:, :, 2); |
|||
blueChannel = image(:, :, 3); |
|||
|
|||
segImR = clusters; |
|||
segImG = clusters; |
|||
segImB = clusters; |
|||
%calculateNcut(graph, clusters); |
|||
unique(clusters) |
|||
|
|||
for cluster = 1:k |
|||
meanR = mean(redChannel(clusters == cluster)); |
|||
meanG = mean(greenChannel(clusters == cluster)); |
|||
meanB = mean(blueChannel(clusters == cluster)); |
|||
|
|||
segImR(clusters == cluster) = meanR; |
|||
segImG(clusters == cluster) = meanG; |
|||
segImB(clusters == cluster) = meanB; |
|||
end |
|||
|
|||
segIm = zeros(size(image, 1), size(image, 2), 3); |
|||
segIm(:, :, 1) = segImR; |
|||
segIm(:, :, 2) = segImG; |
|||
segIm(:, :, 3) = segImB; |
|||
imshow(segIm) |
|||
clusters = reshape(clusters, size(image, 1), []); |
|||
imshow(meanClustersColorRGB(imageT, clusters)) |
|||
|
|||
clearvars segImR segImG segImB meanR meanG meanB graph redChannel ... |
|||
greenChannel blueChannel clusters k image cluster segIm |
|||
clearvars graph clusters k image |
Loading…
Reference in new issue