I am going to build a mushroom identification application and using neural networks for image classification. Right now I am thinking about different image processing methods to implement before feeding my data (mushroom pictures) to the neural network. As one solution I have stumbled into background subtraction, which sounds rather sensible solution as almost all mushroom pictures have forest (similar) background. Yet I have not found any adequate proof that it is used in image classification.

So my question is, whether it is a common practice to remove background from images before using them to train neural network for image classification?

  • $\begingroup$ i dont think its common practise (partly because the background helps identify items in internet/stock photos ; eg blue sky for plane) $\endgroup$
    – seanv507
    Mar 16, 2019 at 18:43
  • $\begingroup$ Yes, but if the goal is the identification between different mushrooms, which almost all have the same background? @seanv507 $\endgroup$
    – Andry
    Mar 16, 2019 at 18:46
  • $\begingroup$ i am not an expert, but would advise against it. unless your background subtraction is perfect. one of the main benefits of conv nets is the optimisation of the end to end process. $\endgroup$
    – seanv507
    Mar 16, 2019 at 18:57
  • $\begingroup$ Sorry I can't help but say -- I hope there's very little chance that such an application would ever be used by non-experts to potentially decide on what types of mushrooms are or are not safe to eat... $\endgroup$
    – Mark
    Apr 1, 2019 at 21:48

2 Answers 2


I tried this several times in several projects in the past, and yes, it may help if done properly. However, reliable background removal is not trivial, and it has to be carefully, manually checked for each image. And as it's not a very easy thing to do, it's not commonly done when working with neural networks and large datasets. Usually, a better approach is to ensure that you have a large number of images with diverse backgrounds, so that the network cannot just rely on the background to drive the prediction.

As a fun fact, from a Marvin Minsky Interview:

[...] Where a perceptron had been trained to distinguish between - this was for military purposes - it was looking at a scene of a forest in which there were camouflaged tanks in one picture and no camouflaged tanks in the other. And the perceptron - after a little training - made a 100% correct distinction between these two different sets of photographs. Then they were embarrassed a few hours later to discover that the two rolls of film had been developed differently. And so these pictures were just a little darker than all of these pictures and the perceptron was just measuring the total amount of light in the scene. But it was very clever of the perceptron to find some way of making the distinction.


I cannot comment for the low reputation. Anyway, as seen as I have read about Image Classification it is not a common practice, especially for large databases. The most common preprocessing operations are transforming the range between [0, 1] or [-1,1] (like in ResNet50V2) and resizing the images to all the same width and height to use a batch size different than 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.