Skip to content

Commit ab1b7c4

Browse files
Merge pull request #329 from feature-creature/master
fixes width, height, getData method calls. Thanks @feature-creature !
2 parents 3d87b5a + 2cf228b commit ab1b7c4

File tree

1 file changed

+8
-8
lines changed
  • chapters/image_processing_computer_vision

1 file changed

+8
-8
lines changed

chapters/image_processing_computer_vision/chapter.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ void ofApp::draw(){
7777
ofSetColor(255);
7878

7979
// We fetch the ofImage's dimensions and display it 10x larger.
80-
int imgWidth = myImage.width;
81-
int imgHeight = myImage.height;
80+
int imgWidth = myImage.getWidth();
81+
int imgHeight = myImage.getHeight();
8282
myImage.draw(10, 10, imgWidth * 10, imgHeight * 10);
8383
}
8484
```
@@ -303,7 +303,7 @@ Most of the time, you'll be working with image data that is stored in a higher-l
303303

304304
```cpp
305305
int arrayIndex = (y * imgWidth) + x;
306-
unsigned char* myImagePixelBuffer = myImage.getPixels();
306+
unsigned char* myImagePixelBuffer = myImage.getPixels().getData();
307307
unsigned char pixelValueAtXY = myImagePixelBuffer[arrayIndex];
308308
```
309309

@@ -577,7 +577,7 @@ ofImage myImage;
577577
myImage.load ("colorful.jpg");
578578
int imageWidth = myImage.getWidth();
579579
int imageHeight = myImage.getHeight();
580-
unsigned char* rgbPixelData = myImage.getPixels();
580+
unsigned char* rgbPixelData = myImage.getPixels().getData();
581581

582582
// Allocate memory for storing a grayscale version.
583583
// Since there's only 1 channel of data, it's just w*h.
@@ -652,15 +652,15 @@ void ofApp::setup(){
652652

653653
// Construct and allocate a new image with the same dimensions.
654654
// This will store our destination ("dst") image.
655-
int imgW = lincolnOfImageSrc.width;
656-
int imgH = lincolnOfImageSrc.height;
655+
int imgW = lincolnOfImageSrc.getWidth();
656+
int imgH = lincolnOfImageSrc.getHeight();
657657
lincolnOfImageDst.allocate(imgW, imgH, OF_IMAGE_GRAYSCALE);
658658

659659
// Acquire pointers to the pixel buffers of both images.
660660
// These images use 8-bit unsigned chars to store gray values.
661661
// Note the convention 'src' and 'dst' -- this is very common.
662-
unsigned char* srcArray = lincolnOfImageSrc.getPixels();
663-
unsigned char* dstArray = lincolnOfImageDst.getPixels();
662+
unsigned char* srcArray = lincolnOfImageSrc.getPixels().getData();
663+
unsigned char* dstArray = lincolnOfImageDst.getPixels().getData();
664664

665665
// Loop over all of the destination image's pixels.
666666
// Each destination pixel will be 10 gray-levels brighter

0 commit comments

Comments
 (0)