Skip to content

Commit 5aec646

Browse files
committed
Getting things set up to talk about color to grayscale conversion
1 parent 87e4d2b commit 5aec646

File tree

1 file changed

+5
-4
lines changed
  • chapters/image_processing_computer_vision

1 file changed

+5
-4
lines changed

chapters/image_processing_computer_vision/chapter.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void ofApp::draw(){
351351
ofDrawEllipse (maxBrightnessX, maxBrightnessY, 40,40);
352352
}
353353
```
354-
Our application locates the bright spot of the laser (which, luckily for us, is the brightest part of the scene) and draws a circle around it. Of course, now that we know where the brightest (or darkest) spot is, we can can develop many interesting applications, such as sun trackers, turtle trackers...
354+
Our application locates the bright spot of the laser (which, luckily for us, is the brightest part of the scene) and draws a circle around it. Of course, now that we know where the brightest (or darkest) spot is, we can can develop many other interesting applications, such as sun trackers, turtle trackers...
355355

356356
![Laser Tag by GRL](images/laser_tag_result.jpg)
357357

@@ -446,7 +446,7 @@ unsigned char redValueAtXY = buffer[rArrayIndex];
446446
unsigned char greenValueAtXY = buffer[gArrayIndex];
447447
unsigned char blueValueAtXY = buffer[bArrayIndex];
448448
```
449-
This is, then, the three-channel "RGB version" of the elementary `index = y*width + x` pattern we used earlier to fetch pixel values from monochrome images.
449+
This is, then, the three-channel "RGB version" of the basic `index = y*width + x` pattern we used earlier to fetch pixel values from monochrome images.
450450

451451
Note that you may occasionally encounter libraries or hardware which deliver RGB bytes in a different order, such as BGR.
452452

@@ -488,13 +488,14 @@ It's helpful to know that there's generally a performance penalty for moving ima
488488

489489
Many computer vision algorithms (though not all!) are commonly performed on grayscale or monochome images. If color isn't important to your vision problem, working in grayscale can significantly improve the speed of image processing routines, because it reduces both the number of calculations as well as the amount of memory required to process the data. Assuming your source data is in color (as is common with webcams), depending on your application, you'll either clobber your color image to grayscale directly, or create a grayscale copy for subsequent processing.
490490

491-
The simplest method to convert a color image to grayscale is to clobber its data by changing its OF image type to `OF_IMAGE_GRAYSCALE`. Note that this causes the image to be reallocated and any ofTextures to be updated, so it can be an expensive operation if done frequently. It's also a "destructive operation", in the sense that the color information is lost in the conversion.</p>
491+
The simplest method to convert a color image to grayscale is to clobber its data by changing its OF image type to `OF_IMAGE_GRAYSCALE`. Note that this causes the image to be reallocated and any ofTextures to be updated, so it can be an expensive operation if done frequently. It's also a "destructive operation", in the sense that the image's original color information is lost in the conversion.</p>
492492

493493
```
494494
ofImage myImage;
495495
myImage.loadImage ("colorful.jpg"); // Load a colorful image.
496-
myImage.setImageType (OF_IMAGE_GRAYSCALE); // Poof! I'm grayscale.
496+
myImage.setImageType (OF_IMAGE_GRAYSCALE); // Poof! It's grayscale.
497497
```
498+
The ofxOpenCV addon library provides several methods for converting color imagery to grayscale. For example, the `convertToGrayscalePlanarImage()` and `setFromColorImage()` functions create or set an `ofxCvGrayscaleImage` from color image data stored in an `ofxCvColorImage`:
498499

499500
`[Code to convert RGB to grayscale using ofxCV]`
500501

0 commit comments

Comments
 (0)