<p>Convolutional Neural Networks (CNNs) are high performance tools for image recognition (including semantic segmentation) and have been shown to be <a href="https://arxiv.org/abs/1811.12231" rel="nofollow noreferrer">very sensitive to texture</a>. The field of computer vision has been around way before the current wave of interest in deep learning, however, and there are various other tools that are still relevant - often with smaller requirements for computational resources and/or training data.</p>

<blockquote>
  <p>For this specific problem, is it necessary to use convolutional neural networks? </p>
</blockquote>

<p>It very much depends on what your metrics for success are. There are other tools that do not involve the use of CNNs - whether they will give you a satisfactory level of detection accuracy can only be determined by practical testing. </p>

<blockquote>
  <p>Or is there a way to achieve my goal with a shallow neural network or any other classifier, combined with texture features for example?</p>
</blockquote>

<p>A shallow neural network will have some detection capability, although (unlike CNNs), they do not exhibit <a href="https://stats.stackexchange.com/questions/208936/what-is-translation-invariance-in-computer-vision-and-convolutional-neural-netwo">translational invariance</a> and so are sensitive to small displacements of the target. Such a network is likely to have more success if used to classify small patches of the image; classifying an image patch within a sliding window is not that unlike how a CNN works, of course. It is also possible to <a href="https://aul12.me/machinelearning/2019/06/10/cnn-mlp-1.html" rel="nofollow noreferrer">approximate a CNN using an equivalent multi-layer perceptron (MLP)</a> - that would be another approach, if your definition of 'shallow' permits.</p>

<p><em>Two approaches that do not require neural networks:</em></p>

<p><strong>Histogram of Oriented Gradients</strong> The HOG descriptor extracts image features using a histogram of gradients in the horizontal and vertical axis. This produces a feature vector, that can be classified - such as using a Support Vector Machine (SVM) or shallow neural network (MLP), for example. This would be a viable approach to classifying image patches without using CNNs. The <code>scikit-image</code> package has a <a href="https://scikit-image.org/docs/dev/auto_examples/features_detection/plot_hog.html" rel="nofollow noreferrer">HOG function</a>, and there is a full worked example of classification of HOG features <a href="https://gurus.pyimagesearch.com/lesson-sample-histogram-of-oriented-gradients-and-car-logo-recognition/" rel="nofollow noreferrer">here</a>. From the documentation:</p>

<pre><code>from skimage.feature import hog
from skimage import data, exposure

image = data.astronaut()

fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
                    cells_per_block=(1, 1), visualize=True, multichannel=True)
</code></pre>

<p><strong>Felsenszwalb’s efficient graph based image segmentation</strong>
There are a bunch of segmentation algorithms in the <code>scikit-image.segmentation</code> toolbox. Felsenszwalb’s is one of them, which (broadly speaking) performs a clustering of image regions based on edges. <a href="https://scikit-image.org/docs/dev/api/skimage.segmentation.html#skimage.segmentation.felzenszwalb" rel="nofollow noreferrer">More info here</a>. From the module documentation:</p>

<pre><code>from skimage.segmentation import felzenszwalb
from skimage.data import coffee
img = coffee()
segments = felzenszwalb(img, scale=3.0, sigma=0.95, min_size=5)
</code></pre>

<p>Hope that helps.</p>
Image semantic segmentation of repeating patterns without CNNs
<p>Suppose I have one or multiple tiles consisting of a single pattern (e.g. materials like: wood, concrete, gravel...) that I would like to train my classifier on, and then I'll use the trained classifier to determine to which class each pixel in another image belong.</p>

<p>Below are example of two tiles I would like to train the classifier on:</p>

<p><a href="https://i.stack.imgur.com/8l97k.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/8l97k.jpg" alt="concrete"></a>
<a href="https://i.stack.imgur.com/fS0sh.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fS0sh.jpg" alt="wood"></a></p>

<p>And let's say I want to segment the image below to identify the pixels belonging to the door and those belonging to the wall. It's just an example, I know this image isn't made of exactly the same patterns as the tiles above:</p>

<p><a href="https://i.stack.imgur.com/eas1R.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/eas1R.jpg" alt="door"></a></p>

<p>For this specific problem, is it necessary to use convolutional neural networks? Or is there a way to achieve my goal with a shallow neural network or any other classifier, combined with texture features for example?</p>

<p>I've already implemented a classifier with Scikit-learn which works on tile pixels individually (see code below where <code>training_data</code> is a vector of singletons), but I want instead to train the classifier on texture patterns.</p>

<pre class="lang-py prettyprint-override"><code># train classifier
classifier = SGDClassifier()
classifier.fit(training_data, training_target)

# classify given image
test_data = image_gray.flatten().reshape((-1, 1))
predictions = classifier.predict(test_data)
image_classified = predictions.reshape(image_gray.shape)
</code></pre>

<p>I was reading <a href="https://medium.com/@arthur_ouaknine/review-of-deep-learning-algorithms-for-image-semantic-segmentation-509a600f7b57" rel="noreferrer">this review</a> of recent deep learning methods used for image segmentation and the results seem accurate, but since I've never used any CNN before I feel intimidated by it.</p>