The syntax for displaying an Image with a Calculated Column (in a View only) is:
(you need to set the Datatype to output as anything but Text, different datatype will output different Alignments)
There are 3 default images available by SharePoint
You want the green image to be displayed based on a calculation: this is pseudo code:
IF( [Product cost]-[Materials cost] > 0 , GREEN , NOTHING )
So the full Calculated Column Formula is:
=IF([Product cost]-[Materials cost]>0,"<img src='/_layouts/images/kpidefault-0.gif'>","")
To add the difference as label:
=[Product cost]-[Materials cost] &
IF( [Product cost]-[Materials cost]>0
, "<img src='/_layouts/images/kpidefault-0.gif'>"
It is perfectly valid to add linebreaks and spaces, SharePoint will ignore them when you paste the Formula in the Calculated Column and save it.
If you always start from a texteditor (Notepad) like this, you have more insight in the flow of your Formula.
Excel can be helpfull in building Formulas, as most basic Functions are the same See http://viewmaster365.com/365coach/#/Calculated_Column_Functions_List
It is a PITA to debug Calculated Columns. Because you don't get feedback until you save a Formula (with an undescriptive message) and you end up having to click multiple times to get back to your Formula. I have written a small 'CalcMaster' bookmarklet which hooks into the formula-editor and does a save of the Formula on every keypress; giving immediate feedback. See: https://github.com/Danny-Engelman/CalcMaster
created from a 0, 1 ... Number value
If you want to create an image based on a Number field,
The Formula is (pseudo code):
="<img src='/_layouts/images/kpidefault-" & NUMBER & ".gif'>"
View : iCSR.Priority
Produces an interactive View:
Update #1 HTML only
Here is HTML code to color the profit as text using CSS
& IF( [Product cost]-[Materials cost]>0
, IF( [Product cost]-[Materials cost]<0
& [Product cost]-[Materials cost]