# How to denote a logical matrix (mask) as used in image processing?

Updated Below

In my thesis, I am discussing an image processing mask, which is a matrix of the same size as some image but with ones where that image meets some criteria and zeroes elsewhere. I am wondering what is a good way to describe such a matrix mathematically?

As an example, suppose I have two grayscale images Z1 and Z2, and a matrix M_BothSat that has ones wherever both images are above some saturation threshold t_OS. How would I describe M_BothSat so that

1. It's clear what M_BothSat is.
2. The notation is rigorous enough mathematically for an engineering master's thesis.
3. I can define more masks in the future without introducing ambiguity or conflicting definitions with earlier masks.

I realize this is more a math question than Latex, but I'm betting this is the best place to get an answer to it.

I have included an example of what I'm trying to do below, and several different options I've looked at that all say the same thing in different ways. The red text is my thoughts on each, the black is what I'm proposing using in my thesis. Can anyone either tell me which of these approaches is the best, or suggest another better form of notation, that would be great. My set notation's a little rusty. Thanks.

\documentclass[12pt, oneside]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{color}
\usepackage{amsmath}
\newcommand{\mat}{\ensuremath{\mathbf{#1}}}

\begin{document}

\textcolor{red}{
\textbf{Option 0}
This option uses a combination of plain english and math equation. It works nicely for here, but I'm going to define a series of logical masks $\mat{M}$, and seems it will be confusing to redefine $m_{i,j}$ repeatedly.
}

The areas \textit{saturated in both} images are given by the set $\mat{M}_{BothSat}$ of logical values $m_{i,j}$ such that

\begin{equation}
m_{i,j} = \begin{cases} 1 & \text{if} \quad  z_{i,j,1} > t_{OS} , z_{i,j,2} > t_{OS} \\
\end{cases},
\end{equation}

\textcolor{red}{
\textbf{Option 1}
This expresses what I'm trying to say: $\mat{M}_{BothSat}$ is a matrix the same size as $\mat{Z}$, with ones where $\mat{Z_1}$ and $\mat{Z_2}$ are both less than some threshold $t_{OS}$. However, to my eye this looks horrible. with the two opening squiggly braces. If the one beginning the cases could be made thinner, so that the one closing the overall set is less ambiguous, that might work. }

\begin{equation}
\mat{M}_{BothSat} = \left\{ m_{i,j} | m_{i,j} = \begin{cases} 1 & \text{if} \quad  z_{i,j,1} > t_{OS} , z_{i,j,2} > t_{OS} \\
\end{cases}
\right\},
\end{equation}

\textcolor{red}{
\textbf{Option 2}
This tries to say the same thing, but breaking it apart into two equations. Will this option be confusing if I define a series of different masks $\mat{M}$ with equations like this where each one contains a line defining $m_{i,j}$? }

\begin{gather}
\mat{M}_{BothSat} = \left\{ m_{i,j} \right\} \nonumber
\\m_{i,j} = \begin{cases} 1 & \text{if} \quad  z_{i,j,1} > t_{OS} , z_{i,j,2} > t_{OS} \\
\end{cases},
\end{gather}

\end{document}


Update

I found another post on here about modifying the cases environment, and I used that approach to add a closing brace to the cases environment so it can be placed inside a set notation, thereby making the set's closing brace slightly less visually confusing. Any feedback? Here's an example:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath}
\DeclareMathOperator{\rank}{rank}

\makeatletter
\newenvironment{closedcases}{%
\matrix@check\closedcases\env@closedcases
}{%
\endarray\right\}% \right\lrack
}
\def\env@closedcases{%
\let\@ifnextchar\new@ifnextchar
\left\{
\def\arraystretch{1.2}%
}
\makeatother

\newcommand{\mat}{\ensuremath{\mathbf{#1}}}

\begin{document}

\begin{equation}
\mat{M}_{BothSat} = \left\{ m_{i,j} | m_{i,j} = \begin{closedcases} 1 & \text{if} \quad  z_{i,j,1} > t_{OS} , z_{i,j,2} > t_{OS} \\
0 & \text{else}
\end{closedcases}
\right\},
\end{equation}

\end{document} • When trying to compile your example I get Undefined control sequence. l.17 \global\@altsecnumformattrue. – N.N. Aug 8 '11 at 16:53
• Don't know where that's coming from. I'm building in Windows with MikTex 2.8 and Texnic Center 2 Alpha, and I'm not getting any errors. Are you missing any of the packages I've included? – SSilk Aug 8 '11 at 17:23
• Dunno. I'm using TeX Live 2009. – N.N. Aug 8 '11 at 17:24

Binary images can be represented as a set of coordinates (x, y). In your case: $M_\text{BothSat} = \left{ (i,j) \mid z_{i,j,1} > t_{OS}, z_{i,j,1} > t_{OS} \}$

• I finally had a chance to discuss this notation with my supervisor. I showed him your notation and my cases-within-a-set version (in my post), and he recommended yours since it appears easier to denote unions/ intersections/ negations of binary masks with this notation. We were unsure what a negation of my version would render since it's a set the same size as the original images containing both ones and zeroes. Thanks! – SSilk Aug 24 '11 at 17:15

I am not exactly sure what you want. If you question is how to make one of the braces stand out, does this solution work for you:

\newcommand*{\Cases}{\begin{cases} 1 & \text{if} \quad  z_{i,j,1} > t_{OS} , z_{i,j,2} > t_{OS} \\                                                                                                                                                                                                    0 & \text{if} \quad  \text{else}
\end{cases}
}%
\newcommand*{\VPhantom}{\vphantom{\Cases}}%
\newcommand*{\VPhantomHack}{\vphantom{\Cases^{2}}}%
\newcommand*{\BoldLeftBrace}{\pmb{\left\{\VPhantomHack\right.}}%
\newcommand*{\RightBrace}{\left.\VPhantom\right\}}%
%
\begin{equation}
\mat{M}_{BothSat}
= \BoldLeftBrace m_{i,j} | m_{i,j}
= \Cases \RightBrace,
\end{equation} • No, my question was more about the mathematical notation itself, i.e. how to properly denote something like a binary image. The reason I asked about the braces was that one approach I had considered was to denote M_BothSat as a set in which the value of every entry is denoted by a zero or one, depending on some case. I've added a solution for the cases-within-set-notation scenario in my original post. Thanks. – SSilk Aug 9 '11 at 16:44