# How to write and read image using ACP port, Jupyter

**URL:** <https://discuss.pynq.io/t/how-to-write-and-read-image-using-acp-port-jupyter/122>\
**Category:** Support\
**Created:** [May 23, 2019, 1:44pm UTC](https://discuss.pynq.io/t/how-to-write-and-read-image-using-acp-port-jupyter/122 "2019-05-23T13:44:36Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kiniman2000](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@kiniman2000](https://discuss.pynq.io/u/kiniman2000)\
**Post date:** [May 24, 2019, 8:22am UTC](https://discuss.pynq.io/t/how-to-write-and-read-image-using-acp-port-jupyter/122/5 "2019-05-24T08:22:17Z")

</div>

The code of the IP is the same that shown in the tutorial, is a 2D concolution filter:  
#include \<hls\_video.h\>  
#include \<stdint.h\>

// Get 1080x1920 HD grey image as input (from “image\_in” array)  
// and do 2D convolution on it with a hard coded 3x3 kernel.  
// Processed image is stored in “image\_out” array.

void conv(uint8\_t image\_in[360_640],uint8\_t image\_out[360_640]){  
#pragma HLS INTERFACE s\_axilite port=return bundle=CRTL\_BUS  
#pragma HLS INTERFACE m\_axi depth=691200 port=image\_in offset=slave bundle=CRTL\_BUS  
#pragma HLS INTERFACE m\_axi depth=691200 port=image\_out offset=slave bundle=CRTL\_BUS  
#pragma HLS DATAFLOW  
const char coefficients[3][3] = { {-1,-2,-1},  
{ 0, 0, 0},  
{ 1, 2, 1} };

hls::Mat\<360,640,HLS\_8UC1\> src; // Mat format variables to store images  
hls::Mat\<360,640,HLS\_8UC1\> dst;  
// Convert from axi format to Mat the input image  
hls::AXIM2Mat\<640,uint8\_t,360,640,HLS\_8UC1\>(image\_in,src);  
// Declare a variable kind window for the coefficients  
hls::Window\<3,3,char\> kernel;  
// Convert the coefficients to hls format  
for (int i=0;i\<3;i++){  
for (int j=0;j\<3;j++){  
kernel.val[i][j]=coefficients[i][j];  
}  
}  
// indicates the relative position of a filtered point within the kernel  
hls::Point\_ anchor = hls::Point\_(-1,-1); // means the center of the kernel  
hls::Filter2D(src,dst,kernel,anchor);  
// Convert to Axi format  
hls::Mat2AXIM\<640,uint8\_t,360,640,HLS\_8UC1\>(dst,image\_out);  
}

 ![Block_design](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/1X/70a860649c190c1de6f9d0b5a3b1e9688e965c4b.jpeg)

Thank you!

---

_[View the full topic](https://discuss.pynq.io/t/how-to-write-and-read-image-using-acp-port-jupyter/122)._
