We propose an inverse tone mapping (iTM) method which can both handle the details of low dynamic range (LDR) images and expand the dynamic ranges of the LDR images. The conventional iTM algorithms often fail to precisely restore the details of the input LDR images. To deal with this problem, we take a two-layer approach where each LDR image is separated into a base layer and a detail layer by bilateral filtering. The detail layer is mapped into that of a high dynamic range (HDR) image via linear mapping while the base layer is expanded via linear stretching to the dynamic range of a target display device. Then, the two resultant base and detail layers are used to reconstruct one final HDR image. From this, the details of the reconstructed HDR image can be revived via learned linear mapping. In order to learn the mapping from the LDR detail layer to an HDR detail layer, the HDR-LDR pairs of training patches of detail layers are classified into various groups based on the features of LDR detail patches. For each group, a linear mapping is learned during a training phase, which can then be applied for HDR reconstruction in testing phases. From the experimental results, we observed that proposed method can restore much more details of HDR images than the conventional methods.