Code Monkey home page Code Monkey logo

Comments (3)

rfuruta avatar rfuruta commented on August 10, 2024 1


By adding the following code to line 54 in test.py, you can save the action maps.

a = action.astype(np.uint8)
a = np.transpose(a, (1,2,0))
cv2.imwrite(SAVE_PATH+str(i)+'_'+str(t)+'_action.png', a)

In the saved action maps, each pixel value has the index of the chosen action.
0: pixel value -= 1
1: do nothing
2: pixel value += 1
3: Gaussian filter (sigma=0.5)
.... (see State.py for more details)
After saving the action maps, we colorized them by (a little modified version of) Pascal VOC color map.

from pixelrl.

rfuruta avatar rfuruta commented on August 10, 2024

move_range indicates the number of actions that move the pixel values. e.g., when move_range=3, there are three actions: pixel_value+=1, +=0, and -=1. When move_range=5, there are five actions: pixel_value +=2, +=1, +=0, -=1, and -=2.

act is the action map whose element indicates the index of chosen action at each pixel.
Let us consider the case when move_range=3.
act[b, y, x] = 0, 1, ... , or 8 where b denotes the b-th image in the minibatch, and y, x denote the indices of row and col, respectively.
At the pixel where act[b, y, x] == 0, the pixel value is changed 'pixel_value -= 1' (Line 14-17 in State.py ).

pixelRL/denoise/State.py

Lines 14 to 17 in e0f5d35

neutral = (self.move_range - 1)/2
move = act.astype(np.float32)
move = (move - neutral)/255
moved_image = self.image + move[:,np.newaxis,:,:]

Similarly, pixel_value +=0 is performed at the pixel where act[b, y, x] == 1, and pixel_value += 1 is performed at the pixel where act[b, y, x] == 2 in Line 14-17. The variable move is divided by 255 in Line 16 because the pixel values are normalized into the range [0, 1].

act[b, y, x] == 3, 4, 5, 6, ,7 and 8 correspond to each action: Gaussian filter, bilateral filter, median filter, another Gaussian filter (with different parameters), another bilateral filter (with different parameters), and box filter, respectively.
In Line 26-27, Gaussian filter is performed on the entire image if at least one act[b, y, x] == 3 exists. Similar process is performed in Line 28-37.
Finally, in Line 40, the pixel value after Gaussian filter is performed is chosen at the pixel where act[b, y, x] == 3. Similar process of the other filters is performed in Line 41-45.

from pixelrl.

rgeng5 avatar rgeng5 commented on August 10, 2024

Thank you for the detailed explanation. I hope to generate the action maps to reproduce the Fig.2 and 4 in your 2019 paper. Where would the best place to output them?

from pixelrl.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.