Message Boards Message Boards


Testing duckweed as a fertilizer using the Wolfram Language

Posted 1 month ago
5 Replies
26 Total Likes

enter image description here


Using the Wolfram Language we were able to rapidly and accurately quantify plant health, allowing us to test a promising novel fertilizer.


About half of the human population is currently supported by synthetic fertilizers, but at best only half of the nutrients deposited by these fertilizers actually make it into the plant, with the rest being lost to the environment (Savci, 2012).

human population supported by nitrogen fertilizers

While critical for supporting the human population, the high usage rate and low nutrient uptake of chemical fertilizers leads to global pollution. On top of the environmental degradation, the manufacturing process is expensive and energy intensive. Emerging alternatives are organic fertilizers: they are cheap, natural products (generally waste material) that release their nutrients slowly as they decompose, reducing the risk of overfertilization. However, their nutrient content is not as dense, or as consistent, as the synthetic fertilizers. Still, they have the potential to carry a wider range of nutrients. The pros and cons are summarized below:

pros and cons of synthetic and organic fertilizers

The solution:

Duckweeds are a family of small aquatic plants found all over the world, and could be a promising fertilizer.


Found in almost any temperate, stagnant pond, duckweeds have a very high protein content (higher than soy), leading to a high nitrogen content. Nitrogen is the key ingredient in all modern fertilizers, and is usually the critical factor in determining plant growth. These incredible plants are already being farmed on an industrial scale, for example by Parabel foods in Florida as a protein supplement. Duckweeds also carry other macro- and micro-nutrients critical for fertilizers, such as phosphorus, potassium, magnesium, iron, and copper. Duckweeds grow incredibly quickly, some doubling in biomass every 16 hours. With these three traits, duckweeds could have the nutrient density of synthetic fertilizers while retaining the natural qualities of organic fertilizers, combining the benefits of both while minimizing their drawbacks. Referring to the previous graphic, it's all green.


The question was now how to test this potential fertilizer – most modern procedures assessing the performance of fertilizers can be subjective (measuring stem height or leaf width), destructive (taking leaf sampling), or can only happen once (removing the plant from the soil and measuring change in biomass). Wolfram language provides an alternative solution through NDVI analysis, also known as Normalized Difference in Vegetation Index. When plants undergo photosynthesis, they absorb red light and reflect near-infrared light. This was used by NASA in the 70’s to measure plant health over large areas by subtracting near infrared from red light, and normalizing that by the total amount of red and infrared light to get a ratio that can quantitatively describe plant health.


Zhamilya Bilayova introduced me to NDVI at the Wolfram Summer Camp (2019). She had developed a function that could take in near-infrared and red filtered images, and generate a heatmap based on the calculated NDVI values for each pixel. You can see her community post here.

I was able to add onto her code so that it can efficiently take in large data sets of images, useful for my research application. I then created a function that returned an average numerical NDVI value for a given image, and finally one function that wraps it all together, taking in a large data set of images and spitting out a text file receipt with the average values of each image. These modifications made the system a practical and easy to use tool that could return quantitative results to researchers very quickly.

The first piece of code is the NDVI function that will be applied to each pixel:

NDVIformula[pixel1_,pixel2_]:= (((pixel1-pixel2)/(pixel1+pixel2))+1)     /2;

This is a slightly modified formula that has the values scaled from 0 to 1 instead of -1 to 1, to avoid any negative pixel values when coloring the heatmap.

Then, I made a function that outputted a single, average NDVI value for each picture processed:

NDVIsingle[image_] :=
  Clear[mean, i];
  mean = {0, 0, 0};
  ImageScan[mean += # &, 
   i = ImageApply[NDVIformula, 
       image, {cropconstant, 
        ImageDimensions[image][[2]] - cropconstant}, {cropconstant, 
        ImageDimensions[image][[1]] - cropconstant}], {"B", "R"}]]
  mean[[1]] /= Times @@ ImageDimensions[i]

The "crop constant" variable set to 100 pixels, for unknown reasons both in mine and Zhamilya's code this was required to process images without errors. I then added the functionality to import large sets of images, and to print out receipts of the average values:

NDVIFunction[user_, month_, date_] :=
  Clear[files, dataList, cuts, datres];
  files = 
    StringJoin["C:\\Users\\", ToString@user, 
     "\\USER FILE LOCATION\\", ToString@month, "-", ToString@date]];
  dataList = Import[#] & /@ files;
  cuts = Table[
    StringDrop[FileNames[files][[n]], 104], {n, 1, Length@dataList}];
  datres = 
    Table[NDVIsingle[dataList[[n]]], {n, 1, Length@dataList}]];
  {Export[StringJoin[ToString@month, "-", ToString@date, ".txt"], 
    Riffle[cuts, datres[[2]]]], Print[datres]}

Along with the code, I turned a basic consumer camera into an NDVI sensor by removing the infrared filter and applying my own red filter from Public Lab’s Infragram. This would then make infrared light show up in the “red” channel of a color separated image, as well as having red light show up in the “blue” channel. Using the camera and the code, I then compared the change in plant health over time for cabbage applied with synthetic fertilizer, organic fertilizer, duckweed fertilizer, and a control without fertilizer.


My experiment was set up in a research greenhouse, with 16 late flat Dutch cabbage plants. The synthetic fertilizer was a water-soluble cocktail of salts and minerals, the duckweed fertilizer was a solution of high-quality powdered duckweed from Parabel Foods, and the organic fertilizer was a kelp emulsion. The duckweed and synthetic fertilizers were applied at the same concentration of nitrogen, and the organic fertilizer was applied by the bottles instructions to avoid over-fertilization or improper usage. I selected this variety of cabbage because it had a high nitrogen requirement (250 Kg N/Ha), while also growing quickly – this would make it a good indicator of a fertilizer’s ability to deposit nutrients over a shorter period.

This is what it looked like in the research greenhouse: Greenhouse

I took pictures every alternating day when the greenhouse was open. The first trial ran for about 2 months till COVID-19 forced me to stop this trial, and another trial that just started a week prior. Once I took my pictures, I cropped them to cover the same consistent image, then let my code crunch through them. In total I collected about 400 images. With each pixel as a unique value, I collected about 3 billion data points.

Here is a colorized GIF of one portion of the plots over time:

colorized gif

These are the results of the average NDVI of each plot:

Full Data

At first glance, you may notice that the dip at the beginning and the fair amount of day to day variation. I was still ironing out kinks in my data collection procedure, and on that day the light in the greenhouse was inconsistent from what it usually was. With better photography and lighting I was able to smooth out some of these issues over time. However, the day to day the relative positions of the different variables remains fairly constant – synthetic with the highest NDVI value/plant health, closely followed by duckweed, then with organic and control on the bottom. You may also notice in the middle portion the duckweed lags behind the synthetic – this is because duckweed is a slow release fertilizer, so it took a while to it to release as many nutrients to get the same NDVI as the synthetic. These results are best summarized in this box plot:


You can see how the duckweed and synthetic fertilizers trend closely together, while organic and the control are in a different tier. A statistical test (ANOVA) supports this claim - the duckweed fertilizer's performance was found to be not significantly different from the synthetic fertilizer, while significantly different from the organic and synthetic fertilizers.

While more trials and more robust analyses were cut short with the premature end of the academic year, the results are nonetheless an exciting proof of concept. In a head to head competition, the duckweed can keep up with a gold standard synthetic fertilizer. At the same time, it is still a cheaply farmed natural product that breaks down slowly, mitigating the risk of overfertilization. By using the natural and efficient growth of duckweed to build up a sophisticated fertilizer instead of a chemical plant, we also have a more sustainable manufacturing process. This work opens the door to looking at duckweed as a cleaner, cheaper, equally effective alternative to the fertilizers that support half the human population.


Savci, S. (2012). Investigation of Effect of Chemical Fertilizers on Environment. APCBEE Procedia,1, 287-292. doi:10.1016/j.apcbee.2012.03.047

5 Replies

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

Thank you!

Posted 1 month ago

Well done!

I agree! Well done Arian!

Thank you!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract