[Rtk-users] get simpleRTK image from array

sare Borhani sareh.borhani at gmail.com
Tue Apr 18 09:23:29 CEST 2017


Dear RTK.User,

I'm using python wrapped version of RTK.

I used the only example of that for reconstruction.It works perfectly.
The problem is that I need to simulate an artifact on projection 2D images,
so first I got each 2D images of stack reiImage by
*srtk.GetArrayFromImage(reiImage) *and then I applied a polynomial on that
to simulate an artifact.NOW need to extract these artifacted-images again
to the simpleRTK image to be able to reconstruct it at the end. I thought
maybe *srtk.GetImageFromArray* works, but it doesn't.

rei.SetAxis(semiprincipalaxis)
rei.SetGeometry( geometry )
reiImage = rei.Execute(source)

sampleList = []
for rcount in range(0,127):
    outputName = '/home/PycharmProjects/test/Sample'+ str(rcount)
    #plt.imsave(outputName, srtk.GetArrayFromImage(reiImage
[:,rcount,:]),  cmap='gray')
    sampleList.append(srtk.GetArrayFromImage(reiImage [:,rcount,:]))

test = np.zeros(np.shape(sampleList[0]),dtype=np.float32)

bhImages = []
for reiImage1 in sampleList:
    #img = plt.imread('/home/PycharmProjects/reiOutput/Sample%d'%k)
    #modifiedImg = sampleList[k]
    artifactedreiImg= np.zeros(np.shape(reiImage1),dtype=np.float32)
    for i in range (reiImage1.shape[0]):
        for j in range (reiImage1.shape[1]):
            a = reiImage1[i, j]
            b = (0.00000000018308 * pow(a, 4)) - (0.000000117480729 *
pow(a, 3)) + (0.00001747041637 * pow(a, 2)) + 1.000021291118193 * a

            artifactedreiImg[i, j] = b

    artifactedreiImg = artifactedreiImg.astype(np.float32)

    bhImages.append(artifactedreiImg.astype(np.float32))
    #plt.imsave(outputName, artifactedreiImg, cmap='gray')


*for i,artifactedImage in enumerate(bhImages): bhImage[:,i,:]=
srtk.GetImageFromArray(artifactedImage[:,:])*

in last lines I tried to get the stack of artifacted images like
reiImage and then paste bhImage instead of reiImage for the
reconstruction part. But I got this eror message:TypeError: 'tuple'
object does not support item assignment

First I tried to change the reiImage but it seems its unwritable.

Best regards,
Sareh Borhani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/rtk-users/attachments/20170418/8f69fc39/attachment.htm>


More information about the Rtk-users mailing list