Use Apex:variable to assign image path dynamically.
Here is a sample code.
public class TestStaticResource{
public string ImagePath{
get;set;
}
public TestStaticResource(){
ImagePath='images/yourImage.png';
}
}
<apex:form>
<apex:variable var="var" value="{!ImagePath}"/>
<apex:image url="{!URLFOR($Resource.StaticResuorceName, var)}"/>
</apex:form>