How To Enhance Image Processing With Core Image In IOS Apps

Core Image is a powerful framework for image processing and analysis technology designed to provide real-time processing for still and video images. This helps you easily apply filters to images, such as modifying the hue, exposure or vibrant. It uses the GPU or CPU rendering path to process the image data very fast.

Core Image can be chained with multiple filters to an Image or video frame at once by creating custom effects. Core Image provides us more than 90 built-in filters on iOS and over 120 on OS X. You can set up filters by supplying key-value pairs for a filter’s input parameters. You can use the output of one filter as the input of another filter, to create amazing effects.

Here is how the Core Image is related to the iOS operating system

core-image-1024x415

Before going into Core Image, let’s know about the classes used in the Core Image framework:

CIContext:

The CIContext is a class which provides an evaluation context for rendering a CIImage object. CIContext class is used to take advantage of the built-in Core Image filters while processing an image.

CIImage:

The CIImage is a class which represent an image or holds an image data which may be created from a UIImage, from an image file, or from pixel data.

CIFilter:

The CIFilter class produces a CIImage object as output. A filter takes one or more images as input. The filter class has a dictionary that defines the attributes,so the parameters of a CIFilter object are set and retrieved through the use of key-value pairs. This helps us to add some beautiful effect on the input image.

Sample example:

In this example local image path is used in resource file to apply effects.

// 1 Retrieving the localimage.png path from resource bundle

NSString *filePath =
  [[NSBundle mainBundle] pathForResource:@"localimage" ofType:@"png"];
NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath];

// 2 Converting the normal image to CIImage object by passing the URL of original localimage.png

CIImage *beginImage =
  [CIImage imageWithContentsOfURL:fileNameAndPath];

// 3 Adding the filter SepiaTone effect to the localimage.png

CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
                              keysAndValues: kCIInputImageKey, beginImage,
                    @"inputIntensity", @0.8, nil];
CIImage *outputImage = [filter outputImage];

// 4 showing the output image in the UIImageView

IImage *newImage = [UIImage imageWithCIImage:outputImage];
self.imageView.image = newImage;

Note : Here we can change the value of the CIFilter value which is given 0.8 by using a slider which min value is 0 and max value is 1.

Here we have not used the CIContext to perform an CIFilter as said earlier. It helps us to make it easier.

Lets change the above code to include the CIContex:

CIImage *beginImage =
[CIImage imageWithContentsOfURL:fileNameAndPath];
 
// 1
CIContext *context = [CIContext contextWithOptions:nil];
 
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, beginImage,
@"inputIntensity", @0.8, nil];
CIImage *outputImage = [filter outputImage];
 
// 2
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
 
// 3
UIImage *newImage = [UIImage imageWithCGImage:cgimg];
self.imageView.image = newImage;
 
// 4
CGImageRelease(cgimg);

Let’s see what happened here:

Here we set up the CIContext object. The CIContext takes an NSDictionary that specifies options including the color format and whether the context should run on the CPU/GPU. Here the default values are fine and so you passed as nil for that argument.

Here we used an method on the context object to draw a CGImage. Calling this method createCGImage:fromRect: on the context with the supplied CIImage will give us an output as CGImageRef.

Next, we converted the CGImage to UIImage using “imageWithCGImage”.

At last we release the CGImageRef as CGImage. CGImage is a C API which need to free memory even it runs with ARC.

Note: To know about all available filters write the following code and call the method in viewDidLoad / onLaunch. The filters are written on the console log.

-(void)logAllFilters {
NSArray *properties = [CIFilter filterNamesInCategory:
kCICategoryBuiltIn];
NSLog(@"%@", properties);
for (NSString *filterName in properties) {
CIFilter *fltr = [CIFilter filterWithName:filterName];
NSLog(@"%@", [fltr attributes]);
}
}

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

How To Make Static Framework IOS Device Independent?

In our previous post, we had mentioned the steps to create a Static Library or Framework for iOS. Here, we will illustrate the steps to make it device independent, i.e. the library can be used to develop app for all iOS devices, instead of recreating the code for each device.

Step 1: Create an Aggregate Target

  • Click File >> New Target and create a new Aggregate target in Other menu.

  • Name your aggregate target – like ‘Framework’

xcode_image

 Step 2: Adding the Static Library as a Dependent Target

  • Add the static library target to the ‘Target Dependencies’.

framework-image

Step 3: Build the ‘Other’ Platform

  • To build the ‘Other’ platform, use a ‘Run Script’ phase.

  • Add a new ‘Run Script’ build phase to your ‘Aggregate’ target and paste the following code.
set -e
 
set -e
 
set +u
 
# Avoid recursively calling this script.
 
if [[ $SF_MASTER_SCRIPT_RUNNING ]]
 
then
 
   exit 0
 
fi
 
set -u
 
export SF_MASTER_SCRIPT_RUNNING=1
 
  
 
SF_TARGET_NAME=${PROJECT_NAME}
 
SF_EXECUTABLE_PATH="lib${SF_TARGET_NAME}.a"
 
SF_WRAPPER_NAME="${SF_TARGET_NAME}.framework"
 
  
 
# The following conditionals come from
 
# https://github.com/kstenerud/iOS-Universal-Framework
 
  
 
if [[ "$SDK_NAME" =~ ([A-Za-z]+) ]]
 
then
 
   SF_SDK_PLATFORM=${BASH_REMATCH[1]}
 
else
 
   echo "Could not find platform name from SDK_NAME: $SDK_NAME"
 
   exit 1
 
fi
 
  
 
if [[ "$SDK_NAME" =~ ([0-9]+.*$) ]] then
 
   SF_SDK_VERSION=${BASH_REMATCH[1]}
 
else
 
   echo "Could not find sdk version from SDK_NAME: $SDK_NAME"
 
   exit 1
 
fi
 
  
 
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
 
then
 
   SF_OTHER_PLATFORM=iphonesimulator
 
else
 
   SF_OTHER_PLATFORM=iphoneos
 
fi
 
  
 
if [[ "$BUILT_PRODUCTS_DIR" =~ (.*)$SF_SDK_PLATFORM$ ]]
 
then
 
   SF_OTHER_BUILT_PRODUCTS_DIR="${BASH_REMATCH[1]}${SF_OTHER_PLATFORM}"
 
else
 
   echo "Could not find platform name from build products directory: $BUILT_PRODUCTS_DIR"
 
   exit 1
 
fi
 
  
 
# Build the other platform.
 
xcodebuild -project "${PROJECT_FILE_PATH}" -target "${TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk ${SF_OTHER_PLATFORM}${SF_SDK_VERSION} BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" $ACTION
 
  
 
# Smash the two static libraries into one fat binary and store it in the .framework
 
lipo -create "${BUILT_PRODUCTS_DIR}/${SF_EXECUTABLE_PATH}" "${SF_OTHER_BUILT_PRODUCTS_DIR}/${SF_EXECUTABLE_PATH}" -output "${BUILT_PRODUCTS_DIR}/${SF_WRAPPER_NAME}/Versions/A/${SF_TARGET_NAME}"
 
  
 
# Copy the binary to the other architecture folder to have a complete framework in both.
 
cp -a "${BUILT_PRODUCTS_DIR}/${SF_WRAPPER_NAME}/Versions/A/${SF_TARGET

Step 4: Build to verify

  • Now  you have set up an environment to build a distributable <project_name>.framework

  • Build the ‘Aggregate’ target

  • Expand the Products group in X-Code, right click the static library and click ‘Show in Finder’

Note: If this doesn’t open Finder to show the static library, then try opening

~/Library/Developer/Xcode/DerivedData/<project name>/Build/Products/Debug-iphonesimulator/.

  • In this folder you will find your <project_name>.framework folder.

You can now share the <project_name>.framework among other iOS app developers.

Top 7 Expert Tips And Tricks For IOS 6

iOS 6 is the latest Apple OS that runs on every Apple devices. Its features like friendly user interfaces and the convenience of apps, makes it a smarter operating system.  Perhaps you are an iOS guru. Or maybe a newbie to the operating system, but here we present some tweaks in iOS that you probably never knew. We also hope you love them and enjoy the benefit of this post.

  • Your iPhone Can Read To You:

You can enable the speak option for facilitating the iOS device to read aloud a selected text. You can enable it from the Accessibility option.

Never miss an update from us. Join 10,000+ marketers and leaders.

  • Enable Emoji Keyboard:

Add iconographic symbols in e-mails, messages, tweets and other postings. This feature is shipped with every iOS 6 devise and doesn’t require buying a third-party iPhone application. To get this feature select General, International then Keyboards tab from the settings option.

  • Ask Siri To Find Location By Using The ‘In Transit’ Cue:

You can ask Siri to find you an address by adding some extra word like ‘transit’ in the end of the command. For example “give me the direction to Kennedy International Airport via transit”. iOS will open up the maps apps and display the route.

  • Edit Siri Commands:

Sometimes Siri doesn’t understand your words and might interpret into something else. But you can fix this issue after Siri responds that she doesn’t understand what you’re talking about. Tap the speech bubble where Siri keeps a record of what she interpreted, there find your command, edit it and resubmit the request.

  • Limit The Ad Tracking:

Most users find it annoying to get constant Advertising pop-ups. But iOS allows you limit these accesses as well. Under the General option tap About and then Advertising to Limit the Ad tracking.

  • Take Photos While Shooting Video:

iPhone 5 and iOS 6 allows the users to snap photos and shoot video simultaneously. It appears on the screen in addition to the shutter button.

  • Customize Auto Replies For Rejected Calls:

you can tailor specific messages, explaining the situation why you didn’t answer your calls. By default you will get 3 pre-reserved options. However you can customize these pre-preserved messages too.

I’ve worked with the team at Andolasoft on multiple websites. They are professional, responsive, & easy to work with. I’ve had great experiences & would recommend their services to anyone.

Ruthie Miller, Sr. Mktg. Specialist

Salesforce, Houston, Texas

LEARN MORE

At Andolasoft, our iPhone application developers keep their skills updated with the latest technology and iOS releases to match this competitive market. Here we develop engaging iPhone application to meet our customer’s business requirements.

New Features Updates Of IOS 6.1

Earlier this week, out of uncertainty, Apple released an iOS 6.1 update for iPhone, iPad and iPod touch. This update is the first major update to iOS 6, since its launch in the last year. There have been minor updates before this, such as iOS 6.0.1 and iOS 6.0.2, but they were flawed with issues. The features introduced in iOS 6.1 are not necessarily groundbreaking, but as a fix and improvements to its previous mistakes. Let’s take a look at these features.

Never miss an update from us. Join 10,000+ marketers and leaders.

  • ‘Siri’ Integration To Search Movies:

Siri has made it extremely simple to find movies, and then buy tickets from Fandango. It is also required to install the Fandango iPhone application to make this feature actually work.  Movies lovers would find this feature to be an extremely fitting update.

  • Apple Maps App:

Apple has definitely improved its Map App with this update. Some of the previous bugs are fixed but hasn’t been solved completely. Along with this it has also added a prominent ‘report a problem’ button.

  • Music Controls:

There is a newly fashioned Lock Screen Music controls in iOS 6.1. When the home button is pressed twice, the music controls pops up. It has been featured to access the music even if the screen is locked. The control interfaces and theme also go well with the Music app itself.

  • Fixed Wi-Fi Issues:

iOS 6.1 on iPhone 5 has resolved all issues from iOS 6.0.2 update. The network connection seems to be strong and stable.

Along with all these features it has also fixed the issue of unexpected OS boot where as the power management is still not satisfying with this update.

I’ve worked with the team at Andolasoft on multiple websites. They are professional, responsive, & easy to work with. I’ve had great experiences & would recommend their services to anyone.

Ruthie Miller, Sr. Mktg. Specialist

Salesforce, Houston, Texas

LEARN MORE

Andolasoft is a leading iPhone application development company offering a comprehensive range of iOS solutions to our global customers. With expertise in HTML 5, CSS, iOS, iPhone SDK, and Cocoa framework, we develop stunning applications to reach a wider audience. With the release of iOS 6.1 it has facilitated our developers to explore new possibilities for application development.

iPhone’s iWallet Patent Control The Spending Limit Of Kids

Apple has published latest patent, explaining Apple’s new iwallet concept. It allows the individuals to configure number of accounts, which can be set-up to control the spending limits. This patent is called “Parental Controls” that could help parents to limit their child’s ability to spend money via an iPhone.

Never miss an update from us. Join 10,000+ marketers and leaders.

The control can be configured for categories like, specific places where purchases can take place and the types of transactions which can be allowed. The patent also suggests that, parent will be notified about their child’s activity on the accounts, including the details of the online purchases. The app can also be set for the users, so that they cannot buy some unethical products. The E-Wallet app is enabled with a primary account that is connected to a credit card.

Users are able to use the app to manage transactions using their iPhone. The patent also hints that it will integrate mobile payment solution so that it can be used outside of its ecosystem in the future. It also reveals that the iPhone would integrate NFC (Near field communication) chip for convenience. This technology is still in its early stage of iPhone application development. So NFC enabled monetary transaction may not be secure completely.

I’ve worked with the team at Andolasoft on multiple websites. They are professional, responsive, & easy to work with. I’ve had great experiences & would recommend their services to anyone.

Ruthie Miller, Sr. Mktg. Specialist

Salesforce, Houston, Texas

LEARN MORE

iPhone applications are the fastest evolving apps in the app industry. That’s why at Andolasoft, our iPhone application developers keep their skills updated with the latest technology and iOS releases to match this competitive market. Here we develop engaging iPhone application to meet our customer’s business requirements.